feat(appointment): implement service mode functionality with service slot selection and validation
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { api } from '../lib/api';
|
||||
import type { ApiResponse } from '../lib/api';
|
||||
|
||||
export interface BookingService {
|
||||
uuid: string;
|
||||
name: string;
|
||||
duration_minutes: number | null;
|
||||
price_rials: number;
|
||||
}
|
||||
|
||||
interface BookingServicesData {
|
||||
booking_mode: 'slot' | 'service';
|
||||
buffer_minutes: number;
|
||||
services: BookingService[];
|
||||
}
|
||||
|
||||
/**
|
||||
* روش نوبتدهی و سرویسهای قابلانتخابِ یک پزشک — از endpoint عمومیِ
|
||||
* `appointment-booking-services`. برای سرویسمحور کردن فرمهای ثبت نوبت پنل.
|
||||
*/
|
||||
export function useDoctorBookingServices(doctorUuid: string | null | undefined) {
|
||||
const q = useQuery<ApiResponse<BookingServicesData>>({
|
||||
queryKey: ['booking-services', doctorUuid],
|
||||
queryFn: () => api.get(`/api/v1/appointment-booking-services/${doctorUuid}`),
|
||||
enabled: !!doctorUuid,
|
||||
});
|
||||
|
||||
const data = q.data?.data as BookingServicesData | undefined;
|
||||
return {
|
||||
bookingMode: (data?.booking_mode === 'service' ? 'service' : 'slot') as 'slot' | 'service',
|
||||
bufferMinutes: data?.buffer_minutes ?? 0,
|
||||
services: data?.services ?? [],
|
||||
isLoading: q.isLoading,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user