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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user