Skip to content

Commit

Permalink
feat(admin): added a select / unselect all toggle when choosing the c…
Browse files Browse the repository at this point in the history
…ertification authorities of a certification
  • Loading branch information
agarbe committed Feb 28, 2025
1 parent 1731eb9 commit d5ed589
Showing 1 changed file with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ export const StructureForm = ({
replaceCertificationAuthorities,
]);

const selectOrUnselectAllCertificationAuthorities = (selectAll: boolean) => {
const newCAs =
availableCertificationAuthorities?.map((aca) => ({
id: aca.id,
label: aca.label,
checked: selectAll,
})) || [];
replaceCertificationAuthorities(newCAs);
};

useEffect(() => {
refreshCertificationAuthoritiesList();
}, [
Expand Down Expand Up @@ -159,13 +169,24 @@ export const StructureForm = ({
(certificationAuthoritiesFields.length ? (
<Checkbox
legend="Gestionnaire(s) des candidatures"
options={certificationAuthoritiesFields.map((ca, caIndex) => ({
label: ca.label,
nativeInputProps: {
key: ca.id,
...register(`certificationAuthorities.${caIndex}.checked`),
options={[
{
label: "Tout cocher / décocher",
nativeInputProps: {
onClick: (e) =>
selectOrUnselectAllCertificationAuthorities(
e.currentTarget.checked,
),
},
},
}))}
...certificationAuthoritiesFields.map((ca, caIndex) => ({
label: ca.label,
nativeInputProps: {
key: ca.id,
...register(`certificationAuthorities.${caIndex}.checked`),
},
})),
]}
/>
) : (
<NoCertificationAuthorityAlert className="my-4" />
Expand Down

0 comments on commit d5ed589

Please sign in to comment.