diff --git a/src/app/(private)/espace-projet/[projetId]/estimation/liste/page.tsx b/src/app/(private)/espace-projet/[projetId]/estimation/liste/page.tsx index 720f170a..203f9a18 100644 --- a/src/app/(private)/espace-projet/[projetId]/estimation/liste/page.tsx +++ b/src/app/(private)/espace-projet/[projetId]/estimation/liste/page.tsx @@ -6,57 +6,67 @@ import { redirect } from "next/navigation"; import { EstimationOverviewCard } from "@/src/components/estimation/estimation-overview-card"; import Button from "@codegouvfr/react-dsfr/Button"; import { GenericFicheLink } from "@/src/components/common/generic-save-fiche/generic-fiche-link"; +import { useEffect, useState } from "react"; import { useCanEditProjet } from "@/src/hooks/use-can-edit-projet"; -export default function CreateEstimationPage() { +export default function ListeEstimationPage() { const currentProjet = useProjetsStore((state) => state.getCurrentProjet()); const canEditProjet = useCanEditProjet(currentProjet?.id); + const [shouldRedirect, setShouldRedirect] = useState(false); - if (!currentProjet) { - return null; - } - if (currentProjet.estimations.length < 1) { - if (canEditProjet) { + useEffect(() => { + if (shouldRedirect && currentProjet) { redirect(PFMV_ROUTES.ESPACE_PROJET_CREATION_ESTIMATION(currentProjet.id)); - } else { - return ( -