This commit is contained in:
Helena
2025-09-17 18:23:25 +03:00
parent cd55ddf3f8
commit 4bd88f1b4e
5 changed files with 13 additions and 31 deletions

View File

@@ -55,12 +55,12 @@ const BookingContext = createContext<{
selectedService: StoreProduct | null;
locations: Location[] | null;
selectedLocationId: number | null;
selectedDate?: Date;
selectedDate?: Date | null;
isLoadingTimeSlots?: boolean;
setSelectedService: (selectedService?: StoreProduct) => void;
setSelectedService: (selectedService: StoreProduct | null) => void;
setSelectedLocationId: (selectedLocationId: number | null) => void;
updateTimeSlots: (serviceId: number) => Promise<void>;
setSelectedDate: (selectedDate?: Date) => void;
updateTimeSlots: (serviceIds: number[]) => Promise<void>;
setSelectedDate: (selectedDate: Date | null) => void;
}>({
timeSlots: null,
selectedService: null,

View File

@@ -27,7 +27,7 @@ export const BookingProvider: React.FC<{
const [selectedLocationId, setSelectedLocationId] = useState<number | null>(
null,
);
const [selectedDate, setSelectedDate] = useState<Date>();
const [selectedDate, setSelectedDate] = useState<Date | null>();
const [timeSlots, setTimeSlots] = useState<TimeSlot[] | null>(null);
const [locations, setLocations] = useState<Location[] | null>(null);
const [isLoadingTimeSlots, setIsLoadingTimeSlots] = useState<boolean>(false);
@@ -49,9 +49,12 @@ export const BookingProvider: React.FC<{
const updateTimeSlots = async (serviceIds: number[]) => {
setIsLoadingTimeSlots(true);
try {
const response = await getAvailableTimeSlotsForDisplay(serviceIds, selectedLocationId);
const response = await getAvailableTimeSlotsForDisplay(
serviceIds,
selectedLocationId,
);
setTimeSlots(response.timeSlots);
setLocations(response.locations)
setLocations(response.locations);
} catch (error) {
setTimeSlots(null);
} finally {