fix(user-profile): consume profile from double-nested 200 response
With the backend now returning 200 (lazy-created profile) instead of 404, align the consumers: the profile lives at res.data.data (the endpoint double-nests), so the booking detail and dashboard read that instead of res.data / the raw envelope. Drop the obsolete 404 special handling (empty editable form now comes from the 200 payload), seed the dashboard empty state when the profile has no real data yet, and make the profile POST fall back to PATCH on 409 (already lazy-created). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -86,7 +86,17 @@ function SubmitData({ setStep, data, prevData, setErrors, doctor, isForAnother,
|
||||
if (uuid) {
|
||||
await request.patchUserProfile(payload, uuid);
|
||||
} else {
|
||||
await request.postUserProfile(payload);
|
||||
const userUuid = data?.uuid || Cookies.get("uuid");
|
||||
try {
|
||||
await request.postUserProfile(payload);
|
||||
} catch (err) {
|
||||
// پروفایل از قبل ساخته شده (lazy-create در سمت backend) → بهجای ساخت، ویرایش
|
||||
if (err?.response?.status === 409 && userUuid) {
|
||||
await request.patchUserProfile(payload, userUuid);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const refreshed = await refreshAccessToken();
|
||||
|
||||
Reference in New Issue
Block a user