Skip to content

Commit

Permalink
feat(panorama-formations): ajout du header de la page formation
Browse files Browse the repository at this point in the history
  • Loading branch information
gBusato committed Oct 17, 2024
1 parent d43b70a commit c62104b
Show file tree
Hide file tree
Showing 30 changed files with 537 additions and 359 deletions.
2 changes: 2 additions & 0 deletions server/src/modules/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getDataForPanoramaRegionRoute } from "./usecases/getDataForPanoramaRegi
import { getDemandesRestitutionIntentionsRoute } from "./usecases/getDemandesRestitutionIntentions/getDemandesRestitutionIntentions.route";
import { getDepartementRoute } from "./usecases/getDepartement/getDepartement.route";
import { getDepartementsRoute } from "./usecases/getDepartements/getDepartements.route";
import { getDomaineDeFormationRoute } from "./usecases/getDomaineDeFormation/getDomaineDeFormation.route";
import { getDomainesDeFormationRoute } from "./usecases/getDomainesDeFormation/getDomainesDeFormation.route";
import { getEtablissementRoute } from "./usecases/getEtablissement/getEtablissement.route";
import { getFormationEtablissementsRoutes } from "./usecases/getFormationEtablissements/getFormationEtablissements.routes";
Expand Down Expand Up @@ -64,5 +65,6 @@ export const registerFormationModule = ({ server }: { server: Server }) => {
...searchCampusRoute(server),
...getRepartitionPilotageIntentionsRoute({ server }),
...getDomainesDeFormationRoute({ server }),
...getDomaineDeFormationRoute({ server }),
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { kdb } from "../../../../../db/db";
import {
isInPerimetreIJAcademie,
isInPerimetreIJDepartement,
isInPerimetreIJRegion,
} from "../../../utils/isInPerimetreIJ";

export const getFilters = async () => {
const regions = await kdb
.selectFrom("region")
.select(["region.libelleRegion as label", "region.codeRegion as value"])
.where(isInPerimetreIJRegion)
.execute();

const academies = await kdb
.selectFrom("academie")
.select([
"academie.libelleAcademie as label",
"academie.codeAcademie as value",
"academie.codeRegion as codeRegion",
])
.where(isInPerimetreIJAcademie)
.execute();

const departements = await kdb
.selectFrom("departement")
.select([
"departement.libelleDepartement as label",
"departement.codeDepartement as value",
"departement.codeAcademie as codeAcademie",
"departement.codeRegion as codeRegion",
])
.where(isInPerimetreIJDepartement)
.execute();

return {
regions,
academies,
departements,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { kdb } from "../../../../../db/db";

export const getNsf = (codeNsf: string) =>
kdb
.selectFrom("nsf")
.where("codeNsf", "=", codeNsf)
.selectAll()
.executeTakeFirst();
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { getFilters } from "./getFilters.dep";
export { getNsf } from "./getNsf.dep";
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createRoute } from "@http-wizard/core";

import { Server } from "../../../../server";
import { getDomaineDeFormationSchema } from "./getDomaineDeFormation.schema";
import { getDomaineDeFormation } from "./getDomaineDeFormation.usecase";

export const getDomaineDeFormationRoute = ({ server }: { server: Server }) => {
return createRoute("/domaine-de-formation/:codeNsf", {
method: "GET",
schema: getDomaineDeFormationSchema,
}).handle((props) =>
server.route({
...props,
handler: async (request, response) => {
const { codeNsf } = request.params;
const result = await getDomaineDeFormation(codeNsf);
response.status(200).send(result);
},
})
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { OptionSchema } from "shared/schema/optionSchema";
import { z } from "zod";

const filtersSchema = z.object({
regions: z.array(OptionSchema),
academies: z.array(
OptionSchema.extend({
codeRegion: z.string(),
})
),
departements: z.array(
OptionSchema.extend({
codeRegion: z.string(),
codeAcademie: z.string(),
})
),
});

const queryFiltersSchema = z.object({});

export type Filters = z.infer<typeof queryFiltersSchema>;

export const getDomaineDeFormationSchema = {
params: z.object({
codeNsf: z.string(),
}),
response: {
200: z.object({
codeNsf: z.string(),
libelleNsf: z.string(),
filters: filtersSchema,
}),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Boom from "@hapi/boom";

Check failure on line 1 in server/src/modules/data/usecases/getDomaineDeFormation/getDomaineDeFormation.usecase.ts

View workflow job for this annotation

GitHub Actions / ciserver

Run autofix to sort these imports!
import { getFilters, getNsf } from "./dependencies";

const getDomaineDeFormationFactory =
(
deps = {
getNsf,
getFilters,
}
) =>
async (codeNsf: string) => {
const [nsf, filters] = await Promise.all([
deps.getNsf(codeNsf),
deps.getFilters(),
]);

if (!nsf) {
throw Boom.notFound(
`Le domaine de formation avec le code ${codeNsf} est inconnue`
);
}

return {
codeNsf,
libelleNsf: nsf.libelleNsf,
filters,
};
};

export const getDomaineDeFormation = getDomaineDeFormationFactory();

This file was deleted.

8 changes: 0 additions & 8 deletions ui/app/(wrapped)/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,6 @@ export const Nav = () => {
</NavMenuLink>
</MenuItem>
)}
<MenuItem p="0">
<NavMenuLink
href="/panorama/formation"
segment="panorama/formation"
>
Domaine de formation
</NavMenuLink>
</MenuItem>
<MenuItem p="0">
<NavMenuLink
href="/panorama/lien-metier-formation"
Expand Down
19 changes: 19 additions & 0 deletions ui/app/(wrapped)/domaine-de-formation/[codeNsf]/client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";

import { useStateParams } from "../../../../utils/useFilters";

type Props = {

Check failure on line 5 in ui/app/(wrapped)/domaine-de-formation/[codeNsf]/client.tsx

View workflow job for this annotation

GitHub Actions / ciserver

'Props' is defined but never used. Allowed unused vars must match /^_/u
codeNsf: string;
libelleNsf: string;
};

export const PageDomaineDeFormationClient = () => {
const [filters, setFilters] = useStateParams<{

Check failure on line 11 in ui/app/(wrapped)/domaine-de-formation/[codeNsf]/client.tsx

View workflow job for this annotation

GitHub Actions / ciserver

'filters' is assigned a value but never used. Allowed unused vars must match /^_/u

Check failure on line 11 in ui/app/(wrapped)/domaine-de-formation/[codeNsf]/client.tsx

View workflow job for this annotation

GitHub Actions / ciserver

'setFilters' is assigned a value but never used. Allowed unused vars must match /^_/u
cfd?: string;
codeRegion?: string;
codeDepartement?: string;
codeAcademie?: string;
}>({ defaultValues: {} });

return <p>Hello</p>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const FiltersSection = () => {
return <div>FiltersSection</div>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ShortLink } from "@/components/ShortLink";

Check failure on line 1 in ui/app/(wrapped)/domaine-de-formation/[codeNsf]/components/HeaderSection/AccesRapide.tsx

View workflow job for this annotation

GitHub Actions / ciserver

Run autofix to sort these imports!
import { HStack, StackDivider } from "@chakra-ui/react";

export const AccesRapide = () => {
return (
<HStack
divider={<StackDivider borderColor={"grey.650"} />}
color={"bluefrance.113"}
>
<ShortLink
iconLeft={"ri:map-pin-line"}
label={"Formations"}
href="#formations"
ml={"0px"}
/>
<ShortLink
iconLeft={"ri:link"}
label={"Liens utiles"}
href="#liens-utiles"
/>
<ShortLink
iconRight={"ri:arrow-right-line"}
label={"Ouvrir la console des formations"}
href={`/console/formations`}
target="_blank"
/>
</HStack>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"use client";

import { getNsfIcon } from "@/utils/getNsfIcon";

Check failure on line 3 in ui/app/(wrapped)/domaine-de-formation/[codeNsf]/components/HeaderSection/HeaderSection.tsx

View workflow job for this annotation

GitHub Actions / ciserver

Run autofix to sort these imports!
import { Flex, Heading, Icon, Img } from "@chakra-ui/react";
import { Icon as Iconify } from "@iconify/react";
import { AccesRapide } from "./AccesRapide";

export const HeaderSection = ({
codeNsf,
libelleNsf,
}: {
codeNsf: string;
libelleNsf: string;
}) => {
return (
<Flex justifyContent={"space-between"} direction={"row"} py={"16px"}>
<Flex direction={"column"} alignItems={"start"} gap={"24px"}>
<Flex
direction={"row"}
alignItems={"center"}
justifyContent={"center"}
gap={"16px"}
>
<Icon
as={Iconify}
icon={getNsfIcon(codeNsf)}
borderRadius={"full"}
boxSize={"54px"}
bgColor={"white"}
p={"8px"}
/>
<Heading as="h1" size="lg" fontSize={{ base: "32px" }}>
{libelleNsf}
</Heading>
</Flex>
<AccesRapide />
</Flex>

<Img
src="/illustrations/team-at-work.svg"
objectFit="contain"
alt="Illustration équipe en collaboration"
/>
</Flex>
);
};
Loading

0 comments on commit c62104b

Please sign in to comment.