40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
/**
|
|
* Hook d'orchestration du flux simulation EE — consommateur de SimulationFlowProvider.
|
|
*
|
|
* Depuis la refonte /sujets (Option A), l'état vit dans le Provider pour survivre
|
|
* aux navigations entre /simulation/ee et /sujets. Ce hook ajoute la navigation
|
|
* vers /sujets après création d'une simulation pour une tâche avec catalogue.
|
|
*
|
|
* Règle H : aucune logique métier — les gardes de quota et de plan sont dans
|
|
* TaskSelector (UX) et dans le backend (autorité).
|
|
*/
|
|
|
|
import { useNavigate } from 'react-router-dom'
|
|
import { useSimulationFlow } from '../state/simulationFlow'
|
|
|
|
export function useSimulation() {
|
|
const navigate = useNavigate()
|
|
const flow = useSimulationFlow()
|
|
|
|
/** Retour à /sujets depuis SimulationForm (bouton "Changer de sujet"). */
|
|
function goToSubjectPicker(): void {
|
|
flow.setStep('choosing-subject')
|
|
navigate('/sujets')
|
|
}
|
|
|
|
return {
|
|
step: flow.step,
|
|
production: flow.production,
|
|
sujet: flow.sujet,
|
|
report: flow.report,
|
|
isCreating: flow.isCreating,
|
|
isCorrecting: flow.isCorrecting,
|
|
createError: flow.createError,
|
|
correctError: flow.correctError,
|
|
selectTask: flow.selectTask,
|
|
submitText: flow.submitText,
|
|
changeSubject: flow.changeSubject,
|
|
goToSubjectPicker,
|
|
reset: flow.reset,
|
|
}
|
|
}
|