mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* mv useTeamMembersWithSegment * remove * fix ts error * remove * remove * remove * biome rule * wip * refactor: remove remaining @calcom/trpc/server imports from atoms - Create local types for schedule handlers (CreateScheduleHandlerReturn, DuplicateScheduleHandlerReturn, GetAvailabilityListHandlerReturn, CreateScheduleInput) - Create local GetAvailableSlotsResponse type for slots hook - Update imports in useAtomCreateSchedule, useAtomDuplicateSchedule, useAtomGetAllSchedules, and useAvailableSlots Co-Authored-By: [email protected] <[email protected]> * fix * fix: add userId to Schedule type and create ScheduleForList type - Schedule type now includes userId for create/duplicate handlers - Created ScheduleForList type for list handler (uses select without userId) Co-Authored-By: [email protected] <[email protected]> * fix * fix * fix * fix * fix: correct fromUser/toUser types in GetAvailableSlotsResponse - fromUser: { id, displayName } (matches IFromUser) - toUser: { id, username, displayName } (matches IToUser) Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
31 lines
975 B
TypeScript
31 lines
975 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
|
|
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
|
import type { ApiResponse } from "@calcom/platform-types";
|
|
|
|
import http from "../../lib/http";
|
|
import type { GetAvailabilityListHandlerReturn } from "./types";
|
|
import { useAtomsContext } from "../useAtomsContext";
|
|
|
|
export const QUERY_KEY = "use-atom-user-schedules";
|
|
|
|
export const useAtomGetAllSchedules = () => {
|
|
const pathname = "atoms/schedules/all";
|
|
const { isInit, accessToken } = useAtomsContext();
|
|
|
|
const { isLoading, error, data, refetch } = useQuery({
|
|
queryKey: [QUERY_KEY],
|
|
queryFn: () => {
|
|
return http.get<ApiResponse<GetAvailabilityListHandlerReturn>>(pathname).then((res) => {
|
|
if (res.data.status === SUCCESS_STATUS) {
|
|
return res.data.data;
|
|
}
|
|
throw new Error(res.data.error?.message);
|
|
});
|
|
},
|
|
enabled: isInit && !!accessToken,
|
|
});
|
|
|
|
return { isLoading, error, data, refetch };
|
|
};
|