From 0ca01c3bf4ad7c85d14643cfa21c82856c916778 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?BITARD=20Micha=C3=ABl?= <michael.bitard@beta.gouv.fr>
Date: Wed, 12 Mar 2025 16:14:34 +0000
Subject: [PATCH] =?UTF-8?q?fix(phases):=20on=20affiche=20la=20liste=20des?=
 =?UTF-8?q?=20d=C3=A9marches=20quand=20on=20a=20plusieurs=20d=C3=A9marches?=
 =?UTF-8?q?=20sans=20aucune=20phase=20(pub/pnm-public/camino!1672)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 packages/ui/src/components/titre.tsx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/packages/ui/src/components/titre.tsx b/packages/ui/src/components/titre.tsx
index 03355672b..05badb3cf 100644
--- a/packages/ui/src/components/titre.tsx
+++ b/packages/ui/src/components/titre.tsx
@@ -165,7 +165,9 @@ export const PureTitre = defineComponent<Props>(props => {
 
         let demarcheSlug = props.currentDemarcheSlug
 
-        if (
+        if (isNullOrUndefinedOrEmpty(demarcheSlug) && 'erreur' in phases.value) {
+          demarcheSlug = phases.value.demarches[0].slug
+        } else if (
           (isNullOrUndefinedOrEmpty(demarcheSlug) || isNullOrUndefined(data.demarches.find(({ slug }) => slug === props.currentDemarcheSlug))) &&
           !('erreur' in phases.value) &&
           phases.value.length > 0
@@ -195,8 +197,10 @@ export const PureTitre = defineComponent<Props>(props => {
 
   watch(
     () => props.titreIdOrSlug,
-    async () => {
+    async (newValue, oldValue) => {
+      console.log('PLOP', props.titreIdOrSlug, newValue, oldValue)
       if (titreData.value.status !== 'LOADED' || (titreData.value.value.id !== props.titreIdOrSlug && titreData.value.value.slug !== props.titreIdOrSlug)) {
+        console.log('Changement de titre')
         await updateTitre(props.titreIdOrSlug)
       }
     }
-- 
GitLab