fix(dashboard): fetch profile by real user uuid, not OTP uuid

app/dashboard/page.js fetched the profile with the standalone uuid cookie,
which still holds the OTP uuid and 404s. Read the user uuid from the
userInfo cookie (falling back to the uuid cookie); the backend resolves it
and lazy-creates the profile. Also fix buildPatientUser to read the
double-nested response (data.data) and the profile's label field.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 19:17:50 +03:30
co-authored by Claude Opus 4.8
parent 96b1684b82
commit cec6b51f23
2 changed files with 10 additions and 5 deletions
+3 -2
View File
@@ -52,11 +52,12 @@ export function adaptRepresentationDashboard(dashboard) {
}
export function buildPatientUser(profile) {
const data = profile?.data ?? profile ?? {};
// GET /user-profile is double-nested: { data: { data: {...} } } (after fetchReq → response.data)
const data = profile?.data?.data ?? profile?.data ?? profile ?? {};
return {
profile: data.avatar ?? "/assets/images/profile-user.png",
name: [data.name, data.family].filter(Boolean).join(" ").trim(),
name: [data.label ?? data.name, data.family].filter(Boolean).join(" ").trim(),
phone: data.phone ?? data.mobile ?? "",
total_transactions: 0,
number_of_turns: 0,