2022-03-26 23:58:22 +00:00
|
|
|
import { withValidation } from "next-validations";
|
2022-04-01 20:04:42 +00:00
|
|
|
import { z } from "zod";
|
2022-03-26 23:58:22 +00:00
|
|
|
|
2022-03-30 15:37:51 +00:00
|
|
|
import { _AvailabilityModel as Availability } from "@calcom/prisma/zod";
|
2022-03-30 12:17:55 +00:00
|
|
|
|
2022-04-24 00:10:32 +00:00
|
|
|
export const schemaAvailabilityBaseBodyParams = Availability.pick({ userId: true, eventTypeId: true, days: true }).partial();
|
2022-03-30 15:37:51 +00:00
|
|
|
|
|
|
|
export const schemaAvailabilityPublic = Availability.omit({});
|
|
|
|
|
2022-04-01 20:04:42 +00:00
|
|
|
const schemaAvailabilityRequiredParams = z.object({
|
2022-04-24 00:10:32 +00:00
|
|
|
startTime: z.date().or(z.string()).optional(),
|
|
|
|
endTime: z.date().or(z.string()).optional(),
|
|
|
|
days: z.any().optional(),
|
2022-04-01 20:04:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export const schemaAvailabilityBodyParams = schemaAvailabilityBaseBodyParams.merge(
|
|
|
|
schemaAvailabilityRequiredParams
|
|
|
|
);
|
|
|
|
|
2022-03-30 15:37:51 +00:00
|
|
|
export const withValidAvailability = withValidation({
|
|
|
|
schema: schemaAvailabilityBodyParams,
|
2022-03-26 23:58:22 +00:00
|
|
|
type: "Zod",
|
|
|
|
mode: "body",
|
|
|
|
});
|