Skip to content

Commit dfcd9ba

Browse files
committed
feat(admin): added certification prerequisites page
1 parent 19d407a commit dfcd9ba

File tree

4 files changed

+203
-0
lines changed

4 files changed

+203
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"data": {
3+
"getCertification": {
4+
"id": "bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b",
5+
"label": "BP Boucher",
6+
"codeRncp": "37310",
7+
"status": "BROUILLON",
8+
"rncpExpiresAt": 1788127200000,
9+
"rncpDeliveryDeadline": null,
10+
"availableAt": 1688162400000,
11+
"typeDiplome": "Brevet Professionnel (BP)",
12+
"degree": {
13+
"id": "0ee2104b-9bdc-4e44-b232-123cf2e3b9a1",
14+
"label": "Niveau 4 : Baccalauréat"
15+
},
16+
"domains": [],
17+
"competenceBlocs": [
18+
{
19+
"id": "008a6fab-55ad-4412-ab17-56bc4b8e2fd0",
20+
"code": "B1",
21+
"label": "Préparation, présentation, décoration et vente en boucherie",
22+
"competences": [
23+
{
24+
"id": "b8786018-6d24-4538-9622-f4ac62eb1742",
25+
"label": "Réaliser les opérations de préparations des viandes"
26+
},
27+
{
28+
"id": "2cbb6688-7b80-416f-940a-e348246484f8",
29+
"label": "Mettre en valeur les produits notamment l’intégralité de la carcasse dans une démarche de développement durable"
30+
},
31+
{
32+
"id": "2c829da9-ed10-48a3-ae1b-2f7db433c6d8",
33+
"label": "Vendre les produits au client en argumentant et en proposant des conseils culinaires"
34+
},
35+
{
36+
"id": "5aad9206-27a0-4afa-ac28-06d30bab6504",
37+
"label": "Communiquer sur l’étiquetage, la conservation, la traçabilité, les signes officiels de qualité et l’origine des viandes"
38+
}
39+
]
40+
},
41+
{
42+
"id": "cc8f1e74-fcd8-4d8b-b03f-97b3012b015d",
43+
"code": "B2",
44+
"label": "Application des règles relatives à l'alimentation et à l'hygiène, aux locaux et équipements du laboratoire et de l'unité de vente en boucherie",
45+
"competences": [
46+
{
47+
"id": "40300ce1-e877-44e1-af0b-ec3db3ba7eb8",
48+
"label": "Analyser des situations professionnelles nécessitant la connaissance des animaux de boucherie et leurs produits, l’environnement professionnel du boucher et les techniques professionnelles de la boucherie"
49+
},
50+
{
51+
"id": "a8e39ba6-9463-48b2-aa99-f8ce1b83904c",
52+
"label": "Appliquer les règles relatives à l’alimentation, à l’hygiène, aux locaux et équipements dans l’environnement professionnel du boucher et de la boucherie"
53+
}
54+
]
55+
}
56+
]
57+
}
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { stubQuery } from "../../../../utils/graphql";
2+
import certificationBPBoucher from "./fixtures/certification-bp-boucher.json";
3+
4+
function interceptCertification() {
5+
cy.intercept("POST", "/api/graphql", (req) => {
6+
stubQuery(
7+
req,
8+
"activeFeaturesForConnectedUser",
9+
"features/active-features.json",
10+
);
11+
stubQuery(req, "getOrganismForAAPVisibilityCheck", "visibility/admin.json");
12+
stubQuery(
13+
req,
14+
"getMaisonMereCGUQuery",
15+
"account/gestionnaire-cgu-accepted.json",
16+
);
17+
stubQuery(req, "getCertificationForUpdateCertificationPrerequisitesPage", {
18+
data: {
19+
getCertification: {
20+
...certificationBPBoucher.data.getCertification,
21+
},
22+
},
23+
});
24+
});
25+
}
26+
27+
context("when i access the update certification page ", () => {
28+
it("display the page with a correct title", function () {
29+
interceptCertification();
30+
31+
cy.admin(
32+
"http://localhost:3003/admin2/responsable-certifications/certifications/bf78b4d6-f6ac-4c8f-9e6b-d6c6ae9e891b/prerequisites",
33+
);
34+
cy.wait("@activeFeaturesForConnectedUser");
35+
cy.wait("@getMaisonMereCGUQuery");
36+
cy.wait("@getCertificationForUpdateCertificationPrerequisitesPage");
37+
38+
cy.get('[data-test="update-certification-prerequisites-page"]')
39+
.children("h1")
40+
.should("have.text", "Prérequis obligatoires");
41+
});
42+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use client";
2+
import { useParams } from "next/navigation";
3+
import { FormOptionalFieldsDisclaimer } from "@/components/form-optional-fields-disclaimer/FormOptionalFieldsDisclaimer";
4+
import { Breadcrumb } from "@codegouvfr/react-dsfr/Breadcrumb";
5+
import { useUpdatePrerequisitesPage } from "./updatePrerequisites.hook";
6+
7+
type CertificationForPage = Exclude<
8+
ReturnType<typeof useUpdatePrerequisitesPage>["certification"],
9+
undefined
10+
>;
11+
12+
export default function UpdatePrerequisitesPage() {
13+
const { certificationId } = useParams<{
14+
certificationId: string;
15+
}>();
16+
17+
const { certification, getCertificationQueryStatus } =
18+
useUpdatePrerequisitesPage({
19+
certificationId,
20+
});
21+
22+
return getCertificationQueryStatus === "success" && certification ? (
23+
<PageContent certification={certification} />
24+
) : null;
25+
}
26+
27+
const PageContent = ({
28+
certification,
29+
}: {
30+
certification: CertificationForPage;
31+
}) => (
32+
<div data-test="update-certification-prerequisites-page">
33+
<Breadcrumb
34+
currentPageLabel={`${certification.codeRncp} - ${certification.label}`}
35+
homeLinkProps={{
36+
href: `/`,
37+
}}
38+
segments={[
39+
{
40+
label: "Prérequis Obligatoires",
41+
linkProps: {
42+
href: `/responsable-certifications/certifications/${certification.id}/prerequisites`,
43+
},
44+
},
45+
]}
46+
/>
47+
48+
<h1>Prérequis obligatoires</h1>
49+
<FormOptionalFieldsDisclaimer />
50+
<p className="mb-12 text-xl">
51+
Si l’obtention de la certification est conditionnée par la détention de
52+
prérequis, vous les retrouverez ici. Relisez les informations récupérées
53+
depuis France compétences et, si nécessaire, procédez à des corrections
54+
(ordre des prérequis, fautes de frappe...).
55+
</p>
56+
</div>
57+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { useGraphQlClient } from "@/components/graphql/graphql-client/GraphqlClient";
2+
import { graphql } from "@/graphql/generated";
3+
import { useQuery } from "@tanstack/react-query";
4+
5+
const getCertificationQuery = graphql(`
6+
query getCertificationForUpdateCertificationPrerequisitesPage(
7+
$certificationId: ID!
8+
) {
9+
getCertification(certificationId: $certificationId) {
10+
id
11+
codeRncp
12+
label
13+
}
14+
}
15+
`);
16+
17+
export const useUpdatePrerequisitesPage = ({
18+
certificationId,
19+
}: {
20+
certificationId: string;
21+
}) => {
22+
const { graphqlClient } = useGraphQlClient();
23+
24+
const {
25+
data: getCertificationResponse,
26+
status: getCertificationQueryStatus,
27+
} = useQuery({
28+
queryKey: [
29+
certificationId,
30+
"certifiactions",
31+
"getCertificationForUpdateCertificationPrerequisitesPage",
32+
],
33+
queryFn: () =>
34+
graphqlClient.request(getCertificationQuery, {
35+
certificationId,
36+
}),
37+
});
38+
39+
const certification = getCertificationResponse?.getCertification;
40+
41+
return {
42+
certification,
43+
getCertificationQueryStatus,
44+
};
45+
};

0 commit comments

Comments
 (0)