Skip to content

Commit

Permalink
feat(admin-react): display bloc de competence details in accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricss committed Jul 3, 2024
1 parent f9f05ec commit b47eb91
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ const getTextFromCompetence = ({
export const CertificationCompetenceAccordion = ({
competenceBloc,
competenceDetails,
defaultExpanded = false,
}: {
competenceBloc: CertificationCompetenceBloc;
competenceDetails: CertificationCompetenceDetails[];
defaultExpanded?: boolean;
}) => {
const label = competenceBloc.code
? `${competenceBloc.code} - ${competenceBloc.label}`
: competenceBloc.label;

return (
<Accordion
label={`${competenceBloc.code} - ${competenceBloc.label}`}
defaultExpanded
>
<Accordion label={label} defaultExpanded={defaultExpanded}>
{competenceBloc.competences.map((competence) => (
<p key={competence.id}>
<span className="font-bold">{competence.label} :</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default function CertificationSection({
{blocsDeCompetences.map((certificationCompetenceBloc) => (
<CertificationCompetenceAccordion
key={certificationCompetenceBloc.id}
defaultExpanded
competenceBloc={certificationCompetenceBloc}
competenceDetails={certificationCompetenceDetails}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ const getCandidacyById = graphql(`
id
code
label
competences {
id
label
}
}
}
certificationCompetenceDetails {
text
certificationCompetence {
id
label
}
}
aapDecision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { PrerequisitesCard } from "./_components/PrerequisitesCard";
import { SendFileCandidateSection } from "./_components/SendFileCandidateSection";
import { SendFileCertificationAuthoritySection } from "./_components/SendFileCertificateurSection";
import { SwornStatementCard } from "./_components/SwornStatementCard";
import { CertificationCompetenceAccordion } from "@/app/(aap)/candidacies/[candidacyId]/feasibility-aap/_components/DffSummary/_components/CertificationCompetenceAccordion";

const AapFeasibilityPage = () => {
const { candidacyId } = useParams<{
Expand Down Expand Up @@ -66,30 +67,34 @@ const AapFeasibilityPage = () => {
/>
}
>
<ul className="list-none flex flex-col gap-2">
{dematerializedFeasibilityFile?.blocsDeCompetences?.map((bc) => (
<li
key={bc.certificationCompetenceBloc.id}
className="grid grid-cols-[1fr_120px] items-center"
>
<span>
{bc.certificationCompetenceBloc.code
? `${bc.certificationCompetenceBloc.code} - ${bc.certificationCompetenceBloc.label}`
: bc.certificationCompetenceBloc.label}
</span>
<Button
className="w-full"
priority={bc.complete ? "secondary" : "primary"}
linkProps={{
href: `/candidacies/${candidacyId}/feasibility-aap/competencies-blocks/${bc.certificationCompetenceBloc.id}`,
}}
<ul className="list-none flex flex-col">
{dematerializedFeasibilityFile?.blocsDeCompetences?.map(
(bloc) => (
<li
key={bloc.certificationCompetenceBloc.id}
className="flex justify-between items-start pb-0 gap-6"
>
<span className="mx-auto">
{bc.complete ? "Modifier" : "Compléter"}
</span>
</Button>
</li>
))}
<CertificationCompetenceAccordion
key={bloc.certificationCompetenceBloc.id}
competenceBloc={bloc.certificationCompetenceBloc}
competenceDetails={
dematerializedFeasibilityFile?.certificationCompetenceDetails
}
/>
<Button
className="w-[120px] mt-4 flex-none"
priority={bloc.complete ? "secondary" : "primary"}
linkProps={{
href: `/candidacies/${candidacyId}/feasibility-aap/competencies-blocks/${bloc.certificationCompetenceBloc.id}`,
}}
>
<span className="mx-auto">
{bloc.complete ? "Modifier" : "Compléter"}
</span>
</Button>
</li>
),
)}
</ul>
</CandidacySectionCard>
<PrerequisitesCard
Expand Down

0 comments on commit b47eb91

Please sign in to comment.