File tree Expand file tree Collapse file tree 5 files changed +29
-5
lines changed
Expand file tree Collapse file tree 5 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -33,12 +33,14 @@ export const schemaEventTypeBaseBodyParams = EventType.pick({
3333 position : true ,
3434 eventName : true ,
3535 timeZone : true ,
36+ schedulingType : true ,
37+ // START Limit future bookings
3638 periodType : true ,
3739 periodStartDate : true ,
38- schedulingType : true ,
3940 periodEndDate : true ,
4041 periodDays : true ,
4142 periodCountCalendarDays : true ,
43+ // END Limit future bookings
4244 requiresConfirmation : true ,
4345 disableGuests : true ,
4446 hideCalendarNotes : true ,
@@ -51,6 +53,8 @@ export const schemaEventTypeBaseBodyParams = EventType.pick({
5153 slotInterval : true ,
5254 successRedirectUrl : true ,
5355 locations : true ,
56+ bookingLimits : true ,
57+ durationLimits : true ,
5458} )
5559 . merge ( z . object ( { hosts : z . array ( hostSchema ) . optional ( ) . default ( [ ] ) } ) )
5660 . partial ( )
@@ -126,6 +130,8 @@ export const schemaEventTypeReadPublic = EventType.pick({
126130 seatsPerTimeSlot : true ,
127131 seatsShowAttendees : true ,
128132 bookingFields : true ,
133+ bookingLimits : true ,
134+ durationLimits : true ,
129135} ) . merge (
130136 z . object ( {
131137 locations : z
Original file line number Diff line number Diff line change 1- import type { Prisma } from "@prisma/client" ;
1+ import { Prisma } from "@prisma/client" ;
22import type { NextApiRequest } from "next" ;
33import type { z } from "zod" ;
44
@@ -202,10 +202,17 @@ import checkTeamEventEditPermission from "../_utils/checkTeamEventEditPermission
202202export async function patchHandler ( req : NextApiRequest ) {
203203 const { prisma, query, body } = req ;
204204 const { id } = schemaQueryIdParseInt . parse ( query ) ;
205- const { hosts = [ ] , ...parsedBody } = schemaEventTypeEditBodyParams . parse ( body ) ;
205+ const {
206+ hosts = [ ] ,
207+ bookingLimits,
208+ durationLimits,
209+ ...parsedBody
210+ } = schemaEventTypeEditBodyParams . parse ( body ) ;
206211
207212 const data : Prisma . EventTypeUpdateArgs [ "data" ] = {
208213 ...parsedBody ,
214+ bookingLimits : bookingLimits === null ? Prisma . DbNull : bookingLimits ,
215+ durationLimits : durationLimits === null ? Prisma . DbNull : durationLimits ,
209216 } ;
210217
211218 if ( hosts ) {
Original file line number Diff line number Diff line change 1- import type { Prisma } from "@prisma/client" ;
1+ import { Prisma } from "@prisma/client" ;
22import type { NextApiRequest } from "next" ;
33
44import { HttpError } from "@calcom/lib/http-error" ;
@@ -259,12 +259,19 @@ import ensureOnlyMembersAsHosts from "./_utils/ensureOnlyMembersAsHosts";
259259async function postHandler ( req : NextApiRequest ) {
260260 const { userId, isAdmin, prisma, body } = req ;
261261
262- const { hosts = [ ] , ...parsedBody } = schemaEventTypeCreateBodyParams . parse ( body || { } ) ;
262+ const {
263+ hosts = [ ] ,
264+ bookingLimits,
265+ durationLimits,
266+ ...parsedBody
267+ } = schemaEventTypeCreateBodyParams . parse ( body || { } ) ;
263268
264269 let data : Prisma . EventTypeCreateArgs [ "data" ] = {
265270 ...parsedBody ,
266271 userId,
267272 users : { connect : { id : userId } } ,
273+ bookingLimits : bookingLimits === null ? Prisma . DbNull : bookingLimits ,
274+ durationLimits : durationLimits === null ? Prisma . DbNull : durationLimits ,
268275 } ;
269276
270277 await checkPermissions ( req ) ;
Original file line number Diff line number Diff line change @@ -79,7 +79,9 @@ model EventType {
7979 bookingFields Json ?
8080 timeZone String ?
8181 periodType PeriodType @default (UNLIMITED )
82+ /// @zod.custom(imports.coerceToDate)
8283 periodStartDate DateTime ?
84+ /// @zod.custom(imports.coerceToDate)
8385 periodEndDate DateTime ?
8486 periodDays Int ?
8587 periodCountCalendarDays Boolean ?
Original file line number Diff line number Diff line change @@ -608,3 +608,5 @@ export const ZVerifyCodeInputSchema = z.object({
608608} ) ;
609609
610610export type ZVerifyCodeInputSchema = z . infer < typeof ZVerifyCodeInputSchema > ;
611+
612+ export const coerceToDate = z . coerce . date ( ) ;
You can’t perform that action at this time.
0 commit comments