Skip to content

Commit 840ca00

Browse files
committed
fix(mimoquage): fall back when profile.get throws
revu-bot review on #3253: if the profile row is missing (brand new user, deleted profile…), `api.profile.get()` throws and the whole mon-espace page 500s. Catch the rejection and keep rendering with `userPhone=null`, matching the pre-existing behavior — the missing-info modal will prompt for a phone number just like before.
1 parent 9672efd commit 840ca00

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

packages/app/src/app/mon-espace/page.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ export default async function Page() {
2020
// The JWT only captures `phone` at sign-in, so `session.user.phone` goes
2121
// stale as soon as the user saves a phone through the missing-info modal
2222
// and re-triggers it on every render. Reading from the profile table on
23-
// each page load keeps the missing-info gate honest.
24-
const profile = await api.profile.get();
23+
// each page load keeps the missing-info gate honest. Fall back to `null`
24+
// when the profile row is missing so the page still renders (the modal
25+
// will prompt for a phone number just like before).
26+
const profile = await api.profile.get().catch(() => null);
2527

2628
return (
2729
<HydrateClient>
28-
<MonEspacePage siret={effectiveSiret} userPhone={profile.phone ?? null} />
30+
<MonEspacePage
31+
siret={effectiveSiret}
32+
userPhone={profile?.phone ?? null}
33+
/>
2934
</HydrateClient>
3035
);
3136
}

0 commit comments

Comments
 (0)