-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rend chaque voeu parcoursup cliquable (619)
- Loading branch information
1 parent
5dcffcb
commit 0a93ce5
Showing
42 changed files
with
595 additions
and
483 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
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
11 changes: 11 additions & 0 deletions
11
app/front/src/components/Recherche/Recherche.interface.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,11 @@ | ||
export type RechercheProps<T> = { | ||
rechercheCallback: (recherche: string) => T[]; | ||
label: string; | ||
description?: string; | ||
nombreDeCaractèresMinimumRecherche: number; | ||
}; | ||
|
||
export type UseRechercheArgs<T> = { | ||
nombreDeCaractèresMinimumRecherche: RechercheProps<T>["nombreDeCaractèresMinimumRecherche"]; | ||
rechercheCallback: RechercheProps<T>["rechercheCallback"]; | ||
}; |
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,39 @@ | ||
import { RechercheProps } from "./Recherche.interface"; | ||
import useRecherche from "./useRecherche"; | ||
import ChampDeRecherche from "@/components/ChampDeRecherche/ChampDeRecherche"; | ||
import { i18n } from "@/configuration/i18n/i18n.ts"; | ||
|
||
const Recherche = <T extends object>({ | ||
rechercheCallback, | ||
label, | ||
description, | ||
nombreDeCaractèresMinimumRecherche, | ||
}: RechercheProps<T>) => { | ||
const { debouncedSetRecherche, statusChampDeRecherche, nombreDeRésultats } = useRecherche({ | ||
nombreDeCaractèresMinimumRecherche, | ||
rechercheCallback, | ||
}); | ||
|
||
return ( | ||
<div> | ||
<ChampDeRecherche | ||
auChangement={(événement) => debouncedSetRecherche(événement.target.value ?? undefined)} | ||
entête={{ description, label }} | ||
obligatoire={false} | ||
status={statusChampDeRecherche} | ||
/> | ||
<div | ||
aria-live="polite" | ||
className="sr-only" | ||
> | ||
{nombreDeRésultats && nombreDeRésultats > 0 && ( | ||
<p> | ||
{nombreDeRésultats} {i18n.ACCESSIBILITÉ.NOUVEAUX_RÉSULATS} | ||
</p> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Recherche; |
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 { UseRechercheArgs } from "./Recherche.interface"; | ||
import { i18n } from "@/configuration/i18n/i18n"; | ||
import { StatusFormulaire } from "@/types/commons"; | ||
import { useState } from "react"; | ||
import { useDebounceCallback } from "usehooks-ts"; | ||
|
||
export default function useRecherche<T>({ | ||
nombreDeCaractèresMinimumRecherche, | ||
rechercheCallback, | ||
}: UseRechercheArgs<T>) { | ||
const [statusChampDeRecherche, setStatusChampDeRecherche] = useState<StatusFormulaire | undefined>(); | ||
const [nombreDeRésultats, setNombreDeRésultats] = useState<number | undefined>(undefined); | ||
|
||
const lancerRecherche = (recherche?: string): void => { | ||
setStatusChampDeRecherche(undefined); | ||
|
||
if (recherche && recherche.length < nombreDeCaractèresMinimumRecherche) { | ||
setStatusChampDeRecherche({ | ||
type: "erreur" as const, | ||
message: `${i18n.COMMUN.ERREURS_FORMULAIRES.AU_MOINS_X_CARACTÈRES} ${nombreDeCaractèresMinimumRecherche} ${i18n.COMMUN.ERREURS_FORMULAIRES.CARACTÈRES}`, | ||
}); | ||
} else if (recherche) { | ||
const résultats = rechercheCallback(recherche); | ||
setNombreDeRésultats(résultats.length); | ||
|
||
if (résultats.length === 0) { | ||
setStatusChampDeRecherche({ type: "erreur" as const, message: i18n.COMMUN.ERREURS_FORMULAIRES.AUCUN_RÉSULTAT }); | ||
} | ||
} else { | ||
setNombreDeRésultats(undefined); | ||
} | ||
}; | ||
|
||
const debouncedSetRecherche = useDebounceCallback(lancerRecherche, 400); | ||
|
||
return { | ||
statusChampDeRecherche, | ||
debouncedSetRecherche, | ||
nombreDeRésultats, | ||
}; | ||
} |
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ export type TitreProps = { | |
| "text--lead" | ||
| "text--lg" | ||
| "text" | ||
| "text--md" | ||
| "text--sm" | ||
| "text--xs"; | ||
}; |
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
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
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
11 changes: 0 additions & 11 deletions
11
...t/src/features/formation/ui/FicheFormation/ChoixFormation/Ambition/Ambition.interface.tsx
This file was deleted.
Oops, something went wrong.
15 changes: 11 additions & 4 deletions
15
app/front/src/features/formation/ui/FicheFormation/ChoixFormation/Ambition/Ambition.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
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
5 changes: 0 additions & 5 deletions
5
...ront/src/features/formation/ui/FicheFormation/ChoixFormation/ChoixFormation.interface.tsx
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
10 changes: 0 additions & 10 deletions
10
...features/formation/ui/FicheFormation/ChoixFormation/Commentaire/Commentaire.interface.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
5 changes: 2 additions & 3 deletions
5
...front/src/features/formation/ui/FicheFormation/ChoixFormation/Commentaire/Commentaire.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
Oops, something went wrong.