75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const REPEAT_CYCLE_CODES = {
|
|
DAILY: "DAILY",
|
|
WEEKLY: "WEEKLY",
|
|
MONTHLY: "MONTHLY",
|
|
QUARTERLY: "QUARTERLY",
|
|
YEARLY: "YEARLY",
|
|
} as const;
|
|
|
|
export type RepeatCycleCode =
|
|
(typeof REPEAT_CYCLE_CODES)[keyof typeof REPEAT_CYCLE_CODES];
|
|
|
|
export interface ScheduleParams {
|
|
siteId?: string;
|
|
schdlTtl?: string;
|
|
schdlSeCd?: string;
|
|
schdlBgngYmd?: string;
|
|
schdlEndYmd?: string;
|
|
reptYn?: string;
|
|
commSchdlYn?: string;
|
|
useYn?: string;
|
|
}
|
|
|
|
export interface Schedule {
|
|
schdlSn: number;
|
|
siteId: string;
|
|
schdlTtl: string;
|
|
schdlSeCd: string;
|
|
schdlSeNm: string;
|
|
schdlBgngDt: string;
|
|
schdlEndDt: string;
|
|
reptYn: string;
|
|
commSchdlYn: string;
|
|
}
|
|
|
|
const scheduleRepeatSchema = z.object({
|
|
schdlSn: z.number().nullish(),
|
|
reptCycleCd: z.nativeEnum(REPEAT_CYCLE_CODES).nullish(),
|
|
reptDayVl: z.number().nullish(),
|
|
reptDowVl: z.number().nullish(),
|
|
reptMmVl: z.number().nullish(),
|
|
reptQuVl: z.number().nullish(),
|
|
reptEndDt: z.string().nullish(),
|
|
});
|
|
|
|
export const scheduleFormSchema = z.object({
|
|
siteId: z.string(),
|
|
schdlTtl: z.string(),
|
|
schdlSeCd: z.string(),
|
|
schdlBgngDt: z.string(),
|
|
schdlEndDt: z.string(),
|
|
schdlCn: z.string().nullish(),
|
|
reptYn: z.string().nullish(),
|
|
commSchdlYn: z.string().nullish(),
|
|
useYn: z.string().nullish(),
|
|
atflCd: z.string().nullish(),
|
|
reptDto: scheduleRepeatSchema.nullish(),
|
|
});
|
|
|
|
export const scheduleUpdateFormSchema = scheduleFormSchema.omit({
|
|
siteId: true,
|
|
});
|
|
|
|
export type ScheduleFormData = z.infer<typeof scheduleFormSchema>;
|
|
export type ScheduleUpdateFormData = z.infer<typeof scheduleUpdateFormSchema>;
|
|
export type RepeatDto = z.infer<typeof scheduleRepeatSchema>;
|
|
|
|
export interface ScheduleService {
|
|
getSchedules(params?: ScheduleParams): Promise<Schedule[]>;
|
|
getScheduleInfo(schdlSn: number): Promise<Schedule>;
|
|
createSchedule(data: ScheduleFormData): Promise<void>;
|
|
updateSchedule(schdlSn: number, data: ScheduleUpdateFormData): Promise<void>;
|
|
}
|