30 lines
865 B
TypeScript
30 lines
865 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
|
|
import { ENDPOINT } from "@/shared/config";
|
|
|
|
import type { ScheduleSearchParams } from "../model/schedule-interface";
|
|
|
|
import { scheduleApi } from "./schedule-service";
|
|
|
|
export function useSchedules(params?: ScheduleSearchParams) {
|
|
return useQuery({
|
|
queryKey: createSchedulesQueryKey(params),
|
|
queryFn: () => scheduleApi.getSchedules(params),
|
|
refetchOnWindowFocus: false,
|
|
});
|
|
}
|
|
|
|
function createSchedulesQueryKey(params?: ScheduleSearchParams) {
|
|
return [
|
|
ENDPOINT.CMS_SERVICE.SCHEDULES,
|
|
"list",
|
|
params?.siteId ?? "",
|
|
params?.schdlTtl ?? "",
|
|
params?.schdlSeCd ?? "",
|
|
params?.schdlBgngYmd ?? "",
|
|
params?.schdlEndYmd ?? "",
|
|
params?.reptYn ?? "",
|
|
params?.commSchdlYn ?? "",
|
|
];
|
|
}
|