feat: Implement resource-based appointment booking flow
- Updated DoctorPage component to accept bookingResources prop for appointment list. - Added serviceQuery function to serialize service item UUIDs for API requests. - Introduced new API endpoints for fetching booking resources and resource slots. - Enhanced tests for new resource-based booking functionality, including resource selection and service availability. - Created ResourceSelect component for selecting appointment types, including doctor and resource options. - Updated appointment submission logic to include resource_uuid in payload when applicable. - Ensured UI reflects changes in booking flow without disrupting existing doctor-centric experience.
This commit is contained in:
@@ -65,6 +65,28 @@ const getBookingLocations = cache(async (doctorUuid) => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* منابع قابل رزروِ پزشک (دستگاه، اتاق، یونیت) در همهٔ محیطهایش.
|
||||
*
|
||||
* جدا از محلها گرفته میشود چون منبع تقویم خودش را دارد: پزشکی که برنامهٔ هفتگی ندارد
|
||||
* هیچ محلی برنمیگرداند، ولی ممکن است دستگاهش کاملاً قابل رزرو باشد.
|
||||
*/
|
||||
const getBookingResources = cache(async (doctorUuid) => {
|
||||
if (!doctorUuid) return [];
|
||||
try {
|
||||
const res = await fetch(
|
||||
`${API_URL}/api/v1/appointment-booking-resources/${doctorUuid}`,
|
||||
{ next: { revalidate: 3600, tags: [`booking-resources-${doctorUuid}`] } }
|
||||
);
|
||||
if (!res.ok) return [];
|
||||
const json = await res.json();
|
||||
const data = json?.data?.data ?? json?.data ?? {};
|
||||
return Array.isArray(data.resources) ? data.resources : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
export async function generateMetadata({ params }) {
|
||||
const { slug } = await params;
|
||||
const { matchedCity } = await getStateInfo();
|
||||
@@ -144,9 +166,13 @@ async function Doctor({ params }) {
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const [addresses, bookingLocations] = doctor
|
||||
? await Promise.all([getDoctorAddresses(doctor.id), getBookingLocations(doctor.uuid)])
|
||||
: [[], []];
|
||||
const [addresses, bookingLocations, bookingResources] = doctor
|
||||
? await Promise.all([
|
||||
getDoctorAddresses(doctor.id),
|
||||
getBookingLocations(doctor.uuid),
|
||||
getBookingResources(doctor.uuid),
|
||||
])
|
||||
: [[], [], []];
|
||||
|
||||
// آدرسی که در هیچ برنامهٔ نوبتدهی استفاده نشده، محل مراجعه نیست. در کارت
|
||||
// «موقعیت مکانی» میماند (اطلاعات واقعی مطب است) ولی به JSON-LD نمیرود، چون
|
||||
@@ -319,6 +345,7 @@ async function Doctor({ params }) {
|
||||
addresses={addresses}
|
||||
bookableAddressUuids={[...bookableAddressUuids]}
|
||||
bookingLocations={bookingLocations}
|
||||
bookingResources={bookingResources}
|
||||
slug={slug}
|
||||
faq={faq}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user