diff --git a/app/appointment/[doctorId]/page.js b/app/appointment/[doctorId]/page.js index 82be7d6..047c09a 100644 --- a/app/appointment/[doctorId]/page.js +++ b/app/appointment/[doctorId]/page.js @@ -6,8 +6,9 @@ export const metadata = { robots: { index: false, follow: false }, }; -async function Appointment({ params }) { +async function Appointment({ params, searchParams }) { const { doctorId } = await params; + const { clinic_uuid: clinicUuid } = (await searchParams) ?? {}; const { matchedCity } = await getStateInfo(); const API_URL = process.env.NEXT_PUBLIC_API_URL; @@ -23,6 +24,7 @@ async function Appointment({ params }) { doctor={doctor} disabledDates={[]} matchedCity={matchedCity} + initialClinicUuid={typeof clinicUuid === "string" ? clinicUuid : null} /> ); } diff --git a/app/component/date/datePicker/index.js b/app/component/date/datePicker/index.js index 7bccd58..51331c2 100644 --- a/app/component/date/datePicker/index.js +++ b/app/component/date/datePicker/index.js @@ -21,7 +21,7 @@ function gregorianMonthsOf(jalaliMonth) { }); } -function DatePicker({ setDate }) { +function DatePicker({ setDate, clinicUuid = null }) { const params = useParams(); const doctorUuid = params?.doctorId; @@ -34,6 +34,15 @@ function DatePicker({ setDate }) { const secondMonth = moment(baseMonth).add(1, "jMonth"); + // هر محل، روزهای غیرفعال و وضعیت نوبتدهی آنلاین خودش را دارد؛ کش ماهها باید + // با تعویض محل دور ریخته شود وگرنه تقویم محل قبلی باقی میماند. + useEffect(() => { + loadedMonths.current = new Set(); + setDisabledSet(new Set()); + setOnlineEnabled(true); + setAutoSelected(false); + }, [clinicUuid]); + useEffect(() => { if (!doctorUuid) return; @@ -47,7 +56,7 @@ function DatePicker({ setDate }) { targets.forEach(({ year, month }) => { loadedMonths.current.add(`${year}-${month}`); request - .getMonthAvailability(doctorUuid, year, month) + .getMonthAvailability(doctorUuid, year, month, clinicUuid) .then((res) => { const data = res?.data ?? {}; if (data.online_booking_enabled === false) setOnlineEnabled(false); @@ -64,7 +73,7 @@ function DatePicker({ setDate }) { loadedMonths.current.delete(`${year}-${month}`); }); }); - }, [doctorUuid, baseMonth]); + }, [doctorUuid, baseMonth, clinicUuid]); const isDisabled = (date) => { const day = moment(date).startOf("day"); diff --git a/app/component/date/dateTime/index.js b/app/component/date/dateTime/index.js index 0fb6c7d..3364f2d 100644 --- a/app/component/date/dateTime/index.js +++ b/app/component/date/dateTime/index.js @@ -16,6 +16,8 @@ function DateTime({ setSelectedDate, serviceMode = false, selectedServiceUuids = [], + clinicUuid = null, + selectedLocation = null, }) { const [value, setValue] = useState(0); const [hour, setHour] = useState(); @@ -30,9 +32,13 @@ function DateTime({ setValue(newValue); }; - const locationAddress = hour?.location_id - ? doctor?.address?.find((a) => String(a.id) === String(hour.location_id))?.address ?? null - : null; + // آدرس از محل انتخابشده میآید، نه از doctor.address: در محیط کلینیک ممکن است + // آدرس اصلاً در فهرست آدرسهای شخصی پزشک نباشد. + const locationAddress = + selectedLocation?.address ?? + (hour?.location_id + ? doctor?.address?.find((a) => String(a.id) === String(hour.location_id))?.address ?? null + : null); useEffect(() => { if (!date || !doctor?.uuid) return; @@ -44,9 +50,9 @@ function DateTime({ const req = serviceMode ? request - .getServiceSlots(doctor.uuid, dateStr, selectedServiceUuids) + .getServiceSlots(doctor.uuid, dateStr, selectedServiceUuids, clinicUuid) .then(adaptServiceSlots) - : request.getAppointmentSlots(doctor.uuid, dateStr).then(adaptSlots); + : request.getAppointmentSlots(doctor.uuid, dateStr, clinicUuid).then(adaptSlots); req .then((parsed) => { @@ -63,7 +69,7 @@ function DateTime({ setAppo("در حال حاضر، نوبتی برای این روز موجود نمیباشد."); setValue(0); }); - }, [date, doctor?.uuid, serviceMode, selectedServiceUuids]); + }, [date, doctor?.uuid, serviceMode, selectedServiceUuids, clinicUuid]); return (
+ نوبتدهی آنلاین برای این پزشک فعال نیست. +
+ ); + } else if (multiLocation && !locationConfirmed) { + dateStep = ( +1. انتخاب روز
-@@ -10,11 +10,12 @@ function Hour({ doctor, setStep, date, locateVisit, isStep, setSelectedSlot, set date={date} doctor={doctor} setStep={setStep} - locateVisit={locateVisit} setSelectedSlot={setSelectedSlot} setSelectedDate={setSelectedDate} serviceMode={serviceMode} selectedServiceUuids={selectedServiceUuids} + clinicUuid={clinicUuid} + selectedLocation={selectedLocation} /> {!isStep && (
diff --git a/components/appointment/date/index.js b/components/appointment/date/index.js index 8a9b1c0..f614cab 100644 --- a/components/appointment/date/index.js +++ b/components/appointment/date/index.js @@ -11,8 +11,10 @@ function Date({ serviceMode = false, selectedServiceUuids = [], onChangeService, + selectedLocation = null, + clinicUuid = null, + onChangeLocation, }) { - const [locateVisit, setLocateVisit] = useState(true); const [date, setDate] = useState(); return ( @@ -20,25 +22,36 @@ function Date({{`${selectedLocation.title}: `}
+{selectedLocation.address || "—"}
+