fix(lint): 4 erreurs ESLint corrigées — split SimulationFlowProvider, hook conditionnel, ref render, setState effect
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
de69b3ff16
commit
79bbbdc4e8
10 changed files with 82 additions and 50 deletions
|
|
@ -8,7 +8,7 @@
|
|||
* Règle H : aucune logique métier — les mutations s'appuient sur entities/.
|
||||
*/
|
||||
|
||||
import { createContext, useContext, useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import {
|
||||
|
|
@ -17,43 +17,15 @@ import {
|
|||
updateSujet as updateSujetApi,
|
||||
} from '@/entities/production/api'
|
||||
import { correctEe } from '@/entities/report/api'
|
||||
import type {
|
||||
CreateSimulationPayload,
|
||||
Production,
|
||||
SujetData,
|
||||
Tache,
|
||||
} from '@/entities/production/types'
|
||||
import type { CreateSimulationPayload, Production, Tache } from '@/entities/production/types'
|
||||
import type { Report } from '@/entities/report/types'
|
||||
import type { ApiError } from '@/shared/types/api'
|
||||
|
||||
export type SimulationStep =
|
||||
| 'idle'
|
||||
| 'choosing-subject'
|
||||
| 'task-selected'
|
||||
| 'correcting'
|
||||
| 'done'
|
||||
import type { SujetData } from '@/entities/production/types'
|
||||
import { SimulationFlowContext, type FlowValue, type SimulationStep } from './simulationFlow'
|
||||
|
||||
const TACHES_SANS_CATALOGUE: Tache[] = ['EO_T1']
|
||||
const LS_SIMULATION_ID_KEY = 'expria_simulation_id'
|
||||
|
||||
interface FlowValue {
|
||||
step: SimulationStep
|
||||
production: Production | null
|
||||
sujet: SujetData | null
|
||||
report: Report | null
|
||||
isCreating: boolean
|
||||
isCorrecting: boolean
|
||||
createError: ApiError | null
|
||||
correctError: ApiError | null
|
||||
selectTask: (payload: CreateSimulationPayload) => void
|
||||
submitText: (texte: string, nclcCible?: 9 | 10) => void
|
||||
changeSubject: (sujet: SujetData) => void
|
||||
setStep: (step: SimulationStep) => void
|
||||
reset: () => void
|
||||
}
|
||||
|
||||
const SimulationFlowContext = createContext<FlowValue | null>(null)
|
||||
|
||||
export function SimulationFlowProvider({ children }: { children: ReactNode }) {
|
||||
const [step, setStep] = useState<SimulationStep>('idle')
|
||||
const [production, setProduction] = useState<Production | null>(null)
|
||||
|
|
@ -178,11 +150,3 @@ export function SimulationFlowProvider({ children }: { children: ReactNode }) {
|
|||
<SimulationFlowContext.Provider value={value}>{children}</SimulationFlowContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useSimulationFlow(): FlowValue {
|
||||
const ctx = useContext(SimulationFlowContext)
|
||||
if (!ctx) {
|
||||
throw new Error('useSimulationFlow doit être utilisé dans un <SimulationFlowProvider>.')
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue