feat(userAccount): enhance user profile handling with avatar upload and additional user data

This commit is contained in:
hamed
2026-06-19 10:19:52 +03:30
parent f6a3082ac8
commit ea2c0c29ec
7 changed files with 94 additions and 20 deletions
+9 -6
View File
@@ -51,16 +51,19 @@ export function adaptRepresentationDashboard(dashboard) {
};
}
export function buildPatientUser(profile) {
export function buildPatientUser(profile, extras = {}) {
// 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.label ?? data.name, data.family].filter(Boolean).join(" ").trim(),
phone: data.phone ?? data.mobile ?? "",
total_transactions: 0,
number_of_turns: 0,
profile: data.avatar ?? extras.avatar ?? "/assets/images/profile-user.png",
name:
[data.label ?? data.name, data.family].filter(Boolean).join(" ").trim() ||
extras.realName ||
"",
phone: data.phone ?? data.mobile ?? extras.mobile ?? "",
total_transactions: extras.total_transactions ?? 0,
number_of_turns: extras.number_of_turns ?? 0,
national_code: data.national_code ?? "",
gender: data.gender ?? "",
date_of_birth: data.birthday ?? "",