* update booker atom for routing form * remove logs * hide routing form properties from docs * fixup * add comments to explain why certain fields are not defined for routing forms in v2 * chore: routing for handler return team and org id * bump libraries platform * fixup! bump libraries platform * chore: get routing form params to embed * logs to remove * fix import path * chore: handle routing form params in booker embed * wip need router api v2 endpoint * resolve merge conflicts * fixup * fixup! Merge branch 'main' into remove-redirect-on-success-for-platform * fixup! fixup! Merge branch 'main' into remove-redirect-on-success-for-platform * router atom * fix libraries version * cleanup * remove console logs * bump libraries --------- Co-authored-by: Morgan Vernay <[email protected]> Co-authored-by: Morgan <[email protected]>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
|
|
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
|
import type { AvailableSlotsType } from "@calcom/platform-libraries";
|
|
import type { GetAvailableSlotsInput, ApiResponse, ApiSuccessResponse } from "@calcom/platform-types";
|
|
|
|
import http from "../lib/http";
|
|
|
|
export const QUERY_KEY = "get-available-slots";
|
|
|
|
export const useAvailableSlots = ({
|
|
enabled,
|
|
...rest
|
|
}: GetAvailableSlotsInput & { enabled: boolean; isTeamEvent?: boolean; teamId?: number }) => {
|
|
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.shouldServeCache,
|
|
],
|
|
queryFn: () => {
|
|
return http
|
|
.get<ApiResponse<AvailableSlotsType>>("/slots/available", {
|
|
params: rest,
|
|
})
|
|
.then((res) => {
|
|
if (res.data.status === SUCCESS_STATUS) {
|
|
return (res.data as ApiSuccessResponse<AvailableSlotsType>).data;
|
|
}
|
|
throw new Error(res.data.error.message);
|
|
});
|
|
},
|
|
enabled: enabled,
|
|
});
|
|
return availableSlots;
|
|
};
|