fix(navigation): correctifs flux retour post-rapport et post-sujets (reset sticky useEffect)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f51caa1b75
commit
da4e465125
3 changed files with 30 additions and 27 deletions
|
|
@ -8,8 +8,6 @@
|
|||
* Règle H : aucune logique métier — tout est dans useSimulation() et les entités.
|
||||
*/
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { usePlan } from '@/features/dashboard/hooks/usePlan'
|
||||
import { Button } from '@/shared/ui/Button'
|
||||
import { useSimulation } from '../hooks/useSimulation'
|
||||
|
|
@ -30,8 +28,6 @@ function SimulationSkeleton() {
|
|||
}
|
||||
|
||||
export function SimulationPage() {
|
||||
const navigate = useNavigate()
|
||||
|
||||
const {
|
||||
data: planData,
|
||||
isLoading: isPlanLoading,
|
||||
|
|
@ -52,18 +48,12 @@ export function SimulationPage() {
|
|||
reset,
|
||||
} = useSimulation()
|
||||
|
||||
// Redirige vers /sujets dès que la création aboutit pour une tâche avec catalogue.
|
||||
useEffect(() => {
|
||||
if (step === 'choosing-subject' && production) {
|
||||
navigate('/sujets')
|
||||
}
|
||||
}, [step, production, navigate])
|
||||
|
||||
useEffect(() => {
|
||||
if (step === 'done' && production) {
|
||||
navigate(`/rapport/${production.id}`)
|
||||
}
|
||||
}, [step, production, navigate])
|
||||
// Le reset sticky (step='done' ou 'choosing-subject' au retour) est déclenché
|
||||
// explicitement par les callers qui ramènent vers /simulation/ee :
|
||||
// - RapportPage.goToSimulations : reset() avant navigate
|
||||
// - SujetsPage bouton « ← Retour » : reset() avant navigate
|
||||
// Un useEffect réactif ici annulerait les transitions légitimes de
|
||||
// createMutation.onSuccess (idle → choosing-subject → navigate /sujets).
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-2xl px-4 py-6">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue