MED-103: add booking functionality
This commit is contained in:
@@ -3,16 +3,75 @@ import { createContext } from 'react';
|
||||
import { StoreProduct } from '@medusajs/types';
|
||||
import { noop } from 'lodash';
|
||||
|
||||
import { Tables } from '@kit/supabase/database';
|
||||
|
||||
export type Location = Tables<
|
||||
{ schema: 'medreport' },
|
||||
'connected_online_locations'
|
||||
>;
|
||||
|
||||
export type TimeSlotResponse = {
|
||||
timeSlots: TimeSlot[];
|
||||
locations: Location[];
|
||||
};
|
||||
|
||||
export type TimeSlot = {
|
||||
ClinicID: number;
|
||||
LocationID: number;
|
||||
UserID: number;
|
||||
SyncUserID: number;
|
||||
ServiceID: number;
|
||||
HKServiceID: number;
|
||||
StartTime: Date;
|
||||
EndTime: Date;
|
||||
PayorCode: string;
|
||||
serviceProvider?: ServiceProvider;
|
||||
syncedService?: SyncedService;
|
||||
} & { location?: Location };
|
||||
|
||||
export type ServiceProvider = {
|
||||
name: string;
|
||||
id: number;
|
||||
jobTitleEn: string | null;
|
||||
jobTitleEt: string | null;
|
||||
jobTitleRu: string | null;
|
||||
clinicId: number;
|
||||
};
|
||||
|
||||
export type SyncedService = Tables<
|
||||
{ schema: 'medreport' },
|
||||
'connected_online_services'
|
||||
> & {
|
||||
providerClinic: ProviderClinic;
|
||||
};
|
||||
|
||||
export type ProviderClinic = Tables<
|
||||
{ schema: 'medreport' },
|
||||
'connected_online_providers'
|
||||
> & { locations: Location[] };
|
||||
|
||||
const BookingContext = createContext<{
|
||||
timeSlots: string[];
|
||||
timeSlots: TimeSlot[] | null;
|
||||
selectedService: StoreProduct | null;
|
||||
setSelectedService: (selectedService: any) => void;
|
||||
locations: Location[] | null;
|
||||
selectedLocationId: number | null;
|
||||
selectedDate?: Date;
|
||||
isLoadingTimeSlots?: boolean;
|
||||
setSelectedService: (selectedService?: StoreProduct) => void;
|
||||
setSelectedLocationId: (selectedLocationId: number | null) => void;
|
||||
updateTimeSlots: (serviceId: number) => Promise<void>;
|
||||
setSelectedDate: (selectedDate?: Date) => void;
|
||||
}>({
|
||||
timeSlots: [],
|
||||
timeSlots: null,
|
||||
selectedService: null,
|
||||
locations: null,
|
||||
selectedLocationId: null,
|
||||
selectedDate: new Date(),
|
||||
isLoadingTimeSlots: false,
|
||||
setSelectedService: (_) => _,
|
||||
setSelectedLocationId: (_) => _,
|
||||
updateTimeSlots: async (_) => noop(),
|
||||
setSelectedDate: (_) => _,
|
||||
});
|
||||
|
||||
export { BookingContext };
|
||||
|
||||
Reference in New Issue
Block a user