- Remove cal.cache query parameter parsing from booking and slots flows - Set shouldServeCache to false for all booking availability checks - Remove _shouldServeCache from schemas and type definitions - Clean up all references in platform atoms and API endpoints This ensures fresh Google Calendar data is always fetched for conflict checking, preventing bookings when there are actual calendar conflicts.
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
|
|
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
|
import type {
|
|
GetAvailableSlotsInput_2024_04_15,
|
|
ApiResponse,
|
|
ApiSuccessResponse,
|
|
} from "@calcom/platform-types";
|
|
import type { GetAvailableSlotsResponse } from "@calcom/trpc/server/routers/viewer/slots/util";
|
|
|
|
import http from "../lib/http";
|
|
|
|
export const QUERY_KEY = "get-available-slots";
|
|
|
|
export const useAvailableSlots = ({
|
|
enabled,
|
|
...rest
|
|
}: GetAvailableSlotsInput_2024_04_15 & { enabled: boolean }) => {
|
|
const availableSlots = useQuery({
|
|
queryKey: [
|
|
QUERY_KEY,
|
|
rest.startTime,
|
|
rest.endTime,
|
|
rest.eventTypeId,
|
|
rest.eventTypeSlug,
|
|
rest.isTeamEvent ?? false,
|
|
rest.teamId ?? false,
|
|
rest.usernameList,
|
|
rest.routedTeamMemberIds,
|
|
rest.skipContactOwner,
|
|
rest.teamMemberEmail,
|
|
],
|
|
queryFn: () => {
|
|
return http
|
|
.get<ApiResponse<GetAvailableSlotsResponse>>("/slots/available", {
|
|
params: rest,
|
|
})
|
|
.then((res) => {
|
|
if (res.data.status === SUCCESS_STATUS) {
|
|
return (res.data as ApiSuccessResponse<GetAvailableSlotsResponse>).data;
|
|
}
|
|
throw new Error(res.data.error.message);
|
|
});
|
|
},
|
|
enabled: enabled,
|
|
});
|
|
return availableSlots;
|
|
};
|