Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perimeter: Modify perimètre chef de file #56

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions components/api-depot/chef-de-file.js

This file was deleted.

106 changes: 106 additions & 0 deletions components/api-depot/chef-de-file.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import PropTypes from "prop-types";

import { getEPCI, getDepartement, getCommune } from "@/lib/cog";

import CopyToClipBoard from "@/components/copy-to-clipboard";
import {
ChefDeFileApiDepotType,
PerimeterType,
TypePerimeterEnum,
} from "types/api-depot";

function getPerimeters(perimetre: PerimeterType[]) {
return perimetre
? perimetre.map((p) => {
const { type, code } = p;

if (type === TypePerimeterEnum.EPCI) {
return `EPCI de ${getEPCI(code).nom} (${code})`;
}

if (type === TypePerimeterEnum.DEPARTEMENT) {
return `Département de ${getDepartement(code).nom} (${code})`;
}

if (type === TypePerimeterEnum.COMMUNE) {
return `Commune de ${getCommune(code).nom} (${code})`;
}

return "inconnu";
})
: null;
}

interface ChefDeFileProps extends ChefDeFileApiDepotType {
hasChefDeFile: boolean;
}

const ChefDeFile = ({
hasChefDeFile,
_id,
nom,
email,
isEmailPublic,
perimetre,
signataireCharte,
}: ChefDeFileProps) => {
const perimeters = getPerimeters(perimetre);
return (
<div className="fr-py-4v">
<h1 className="fr-m-1v">Chef de file</h1>
{hasChefDeFile ? (
<div className="fr-container fr-py-4v">
<div className="fr-grid-row fr-grid-row--gutters fr-grid-row--middle">
<div className="fr-col-10">
<h3>{nom}</h3>
<CopyToClipBoard text={_id} title="Id" />
<CopyToClipBoard text={email} title="Email" />
<div className="fr-col">
<input
type="checkbox"
id="checkbox"
name="checkbox"
checked={isEmailPublic}
disabled
/>
<label className="fr-label" htmlFor="checkbox">
Email Public
</label>
</div>
</div>

<div className="fr-col">
<input
type="checkbox"
id="checkbox"
name="checkbox"
checked={signataireCharte}
disabled
/>
<label className="fr-label" htmlFor="checkbox">
signataire de la charte
</label>
</div>
</div>

<div className="fr-my-2w">
<label className="fr-label">Périmètre :</label>
<ul>
{perimeters
? perimeters.map((p) => <li key={p}>{p}</li>)
: "Aucune périmètre n’est défini"}
</ul>
</div>
</div>
) : (
<div className="fr-container fr-py-4v">
<div className="fr-grid-row fr-grid-row--gutters">
<div className="fr-col">Aucun chef de file</div>
</div>
</div>
)}
</div>
);
};

export default ChefDeFile;
137 changes: 0 additions & 137 deletions components/api-depot/client/client-form/chef-de-file-form.js

This file was deleted.

Loading
Loading