feat(simulations): hook useSujets + composant SujetSelector
This commit is contained in:
parent
4245d0bcf1
commit
477477b6a6
2 changed files with 174 additions and 0 deletions
21
src/features/simulations/hooks/useSujets.ts
Normal file
21
src/features/simulations/hooks/useSujets.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* Hook de chargement des sujets disponibles pour une tâche.
|
||||
*
|
||||
* Règle H : aucune logique métier ici — mapping Tache → filtres DB dans
|
||||
* `entities/production/api.ts` (getSujets). Le hook ne fait qu'encapsuler
|
||||
* la requête TanStack Query avec un staleTime généreux (le catalogue de
|
||||
* sujets change rarement).
|
||||
*/
|
||||
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getSujets } from '@/entities/production/api'
|
||||
import type { SujetData, Tache } from '@/entities/production/types'
|
||||
|
||||
export function useSujets(tache: Tache, enabled: boolean = true) {
|
||||
return useQuery<SujetData[]>({
|
||||
queryKey: ['sujets', tache],
|
||||
queryFn: () => getSujets(tache),
|
||||
staleTime: 10 * 60 * 1000,
|
||||
enabled,
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue