feat(simulations): hook useSujets + composant SujetSelector

This commit is contained in:
Hermann_Kitio 2026-04-21 01:09:27 +03:00
parent 4245d0bcf1
commit 477477b6a6
2 changed files with 174 additions and 0 deletions

View 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,
})
}