fix(appointment): correct payment flow and account-info prefill
- Booking response is double-nested: read appointment uuid/expires_at from res.data.data so the payment countdown and gateway redirect actually fire. - Payment result page (/payment/[uuid]): unwrap res.data.data, use real backend fields (amount_rials, gateway, created_at, type) and statuses (pending/success/failed/canceled/refunded); the "pay" button now re-initiates via postAppointmentPayment instead of building a URL on the API origin. - Add /payment/result interstitial that reads payment_uuid from the gateway callback and forwards to /payment/[uuid]. - Prefill account info correctly in the booking form: name from profile.label, insurances from *_id, gender as string, national_code editable unless approved. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -125,10 +125,11 @@ function SubmitData({ setStep, data, prevData, setErrors, doctor, isForAnother,
|
||||
};
|
||||
|
||||
const res = await request.postAppointment(appointmentPayload);
|
||||
const appointmentUuid = res?.data?.uuid;
|
||||
const appointment = res?.data?.data;
|
||||
const appointmentUuid = appointment?.uuid;
|
||||
if (appointmentUuid) {
|
||||
setAppointmentId(appointmentUuid);
|
||||
setAppointmentExpiresAt?.(res?.data?.expires_at ?? null);
|
||||
setAppointmentExpiresAt?.(appointment?.expires_at ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,19 +23,22 @@ function buildProfileData(profile, phone) {
|
||||
phone: { value: phone, isEdit: false },
|
||||
national_code: {
|
||||
value: profile.national_code || "",
|
||||
isEdit: profile.national_code ? false : true,
|
||||
isEdit: !profile.national_code_approved,
|
||||
},
|
||||
name: { value: profile.name || "", isEdit: true },
|
||||
name: { value: profile.label || "", isEdit: true },
|
||||
family: { value: profile.family || "", isEdit: true },
|
||||
gender: {
|
||||
value: profile.gender
|
||||
? { id: profile.gender, title: profile.gender === "male" ? "مرد" : "زن" }
|
||||
gender: { value: profile.gender || "", isEdit: true },
|
||||
insurance_id: { value: profile.insurance_id || "", isEdit: true },
|
||||
basic_insurance: {
|
||||
value: profile.basic_insurance_id ? { id: profile.basic_insurance_id } : "",
|
||||
isEdit: true,
|
||||
},
|
||||
supplementary_insurance: {
|
||||
value: profile.supplementary_insurance_id
|
||||
? { id: profile.supplementary_insurance_id }
|
||||
: "",
|
||||
isEdit: true,
|
||||
},
|
||||
insurance_id: { value: profile.insurance_id || "", isEdit: true },
|
||||
basic_insurance: { value: profile.basic_insurance, isEdit: true },
|
||||
supplementary_insurance: { value: profile.supplementary_insurance, isEdit: true },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user