fix(appointment): real status filter + required account fields
- My-appointments tabs sent invalid status values (reserved/waiting_for_payment/ ...) that don't exist in the backend, so every tab but "all" returned empty. Map tabs to real statuses (pending/confirmed/completed/cancelled_by_user/ expired) so booked appointments show up. - Booking form now validates required account fields before proceeding to payment (national_code 10 digits, name, family, gender, basic_insurance), in both self and other-person modes, surfacing per-field errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,26 @@ function SubmitData({ setStep, data, prevData, setErrors, doctor, isForAnother,
|
||||
}
|
||||
};
|
||||
|
||||
const validate = () => {
|
||||
const errs = {};
|
||||
const nationalCode = (data?.national_code?.value || "").trim();
|
||||
if (!data?.name?.value?.trim()) errs.name = "نام الزامی است";
|
||||
if (!data?.family?.value?.trim()) errs.family = "نام خانوادگی الزامی است";
|
||||
if (!nationalCode) errs.national_code = "کد ملی الزامی است";
|
||||
else if (!/^\d{10}$/.test(nationalCode))
|
||||
errs.national_code = "کد ملی باید ۱۰ رقم باشد";
|
||||
if (!data?.gender?.value) errs.gender = "جنسیت الزامی است";
|
||||
if (!data?.basic_insurance?.value?.id) errs.basic_insurance = "نوع بیمه الزامی است";
|
||||
return errs;
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const errs = validate();
|
||||
if (Object.keys(errs).length > 0) {
|
||||
setErrors(errs);
|
||||
return;
|
||||
}
|
||||
|
||||
const isChanged = JSON.stringify(prevData) !== JSON.stringify(data);
|
||||
|
||||
setErrors({});
|
||||
|
||||
@@ -3,20 +3,20 @@ import Tabs from "@/app/component/Tabs";
|
||||
const listTab = [
|
||||
"همه",
|
||||
"در انتظار پرداخت",
|
||||
"رزرو شده",
|
||||
"ویزیت شده",
|
||||
"لغو خودکار",
|
||||
"تکمیل شده",
|
||||
"تأیید شده",
|
||||
"انجام شده",
|
||||
"لغو شده",
|
||||
"منقضی شده",
|
||||
];
|
||||
|
||||
function Head({ status, setStatus }) {
|
||||
const statusMap = {
|
||||
0: undefined, // all
|
||||
1: "waiting_for_payment",
|
||||
2: "reserved",
|
||||
3: "visited",
|
||||
4: "auto_cancel_unpaid",
|
||||
5: "completed",
|
||||
1: "pending",
|
||||
2: "confirmed",
|
||||
3: "completed",
|
||||
4: "cancelled_by_user",
|
||||
5: "expired",
|
||||
};
|
||||
|
||||
const handleChange = (e, value) => {
|
||||
|
||||
Reference in New Issue
Block a user