feat(simulations): choix du sujet — dropdown intégré + bouton aléatoire

This commit is contained in:
Hermann_Kitio 2026-04-21 02:06:08 +03:00
parent 477477b6a6
commit 7902eec042
5 changed files with 193 additions and 29 deletions

View file

@ -16,6 +16,7 @@ import { useQuery } from '@tanstack/react-query'
import { getPlanStatus } from '@/entities/user/api'
import { Button } from '@/shared/ui/Button'
import { useSimulation } from '../hooks/useSimulation'
import { useSujets } from '../hooks/useSujets'
import { TaskSelector } from '../components/TaskSelector'
import { SimulationForm } from '../components/SimulationForm'
@ -55,9 +56,17 @@ export function SimulationPage() {
correctError,
selectTask,
submitText,
changeSubject,
reset,
} = useSimulation()
// Catalogue des sujets pour le dropdown dans SujetDisplay.
// EO_T1 n'a pas de catalogue (getSujets retourne [] — requête court-circuitée côté API).
const {
data: sujets,
isLoading: isLoadingSujets,
} = useSujets(production?.tache ?? 'EE_T1', !!production)
useEffect(() => {
if (step === 'done' && production) {
navigate(`/rapport/${production.id}`)
@ -88,16 +97,21 @@ export function SimulationPage() {
/>
)}
{planData && (step === 'task-selected' || step === 'correcting') && production && (
<SimulationForm
tache={production.tache}
sujet={sujet}
isSubmitting={isCorrecting}
error={correctError}
onSubmit={submitText}
onBack={reset}
/>
)}
{planData &&
(step === 'choosing-subject' || step === 'task-selected' || step === 'correcting') &&
production && (
<SimulationForm
tache={production.tache}
sujet={sujet}
sujets={sujets ?? []}
isLoadingSujets={isLoadingSujets}
isSubmitting={isCorrecting}
error={correctError}
onSubmit={submitText}
onBack={reset}
onChangeSujet={changeSubject}
/>
)}
</main>
)
}