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:
hamed
2026-06-16 10:45:41 +03:30
co-authored by Claude Opus 4.8
parent 59d29cd7c7
commit 7949da9ba9
4 changed files with 237 additions and 9 deletions
@@ -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({});