-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(panorama-formations): ajout du header de la page formation
- Loading branch information
Showing
30 changed files
with
537 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
server/src/modules/data/usecases/getDomaineDeFormation/dependencies/getFilters.dep.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
}; |
8 changes: 8 additions & 0 deletions
8
server/src/modules/data/usecases/getDomaineDeFormation/dependencies/getNsf.dep.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
2 changes: 2 additions & 0 deletions
2
server/src/modules/data/usecases/getDomaineDeFormation/dependencies/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { getFilters } from "./getFilters.dep"; | ||
export { getNsf } from "./getNsf.dep"; |
21 changes: 21 additions & 0 deletions
21
server/src/modules/data/usecases/getDomaineDeFormation/getDomaineDeFormation.route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}, | ||
}) | ||
); | ||
}; |
34 changes: 34 additions & 0 deletions
34
server/src/modules/data/usecases/getDomaineDeFormation/getDomaineDeFormation.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}), | ||
}, | ||
}; |
30 changes: 30 additions & 0 deletions
30
server/src/modules/data/usecases/getDomaineDeFormation/getDomaineDeFormation.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Boom from "@hapi/boom"; | ||
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(); |
70 changes: 0 additions & 70 deletions
70
server/src/modules/data/usecases/getDomainesDeFormation/dependencies/getFormations.dep.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
ui/app/(wrapped)/domaine-de-formation/[codeNsf]/client.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use client"; | ||
|
||
import { useStateParams } from "../../../../utils/useFilters"; | ||
|
||
type Props = { | ||
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 GitHub Actions / ciserver
|
||
cfd?: string; | ||
codeRegion?: string; | ||
codeDepartement?: string; | ||
codeAcademie?: string; | ||
}>({ defaultValues: {} }); | ||
|
||
return <p>Hello</p>; | ||
}; |
3 changes: 3 additions & 0 deletions
3
ui/app/(wrapped)/domaine-de-formation/[codeNsf]/components/FiltersSection/FiltersSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const FiltersSection = () => { | ||
return <div>FiltersSection</div>; | ||
}; |
29 changes: 29 additions & 0 deletions
29
ui/app/(wrapped)/domaine-de-formation/[codeNsf]/components/HeaderSection/AccesRapide.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ShortLink } from "@/components/ShortLink"; | ||
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> | ||
); | ||
}; |
46 changes: 46 additions & 0 deletions
46
ui/app/(wrapped)/domaine-de-formation/[codeNsf]/components/HeaderSection/HeaderSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use client"; | ||
|
||
import { getNsfIcon } from "@/utils/getNsfIcon"; | ||
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> | ||
); | ||
}; |
Oops, something went wrong.