Feat Booking Limits (#4759)
* Add db relevant stuff * Basic UI there still buggy * This UI is hard - some progress * Fix awful state mangament * Fix re-ordering * Working UI logic! * Partical working minMax function * Fix min max * bookingLImits api + tests * Moved checkBookingLimits to backend only code * Fix httperror import * Return busy times * Remove avaliablity calc * Working for everything but year * Remove redundant + fix async forloop * Add compatible type * Future proof with evenTypeId filter * Fix commonjson * Sorting + validation + tests + passing * Add empty test * Move validation check to backend * Add bookinglimits in trpc * Add test for undefined * Apply suggestions from code review Co-authored-by: Jeroen Reumkens <[email protected]> * Update apps/web/components/v2/eventtype/EventLimitsTab.tsx Co-authored-by: Jeroen Reumkens <[email protected]> * Rename value for eligiability * Rename keyof type * status code * Fix toggle not toggling off * Update apps/web/pages/v2/event-types/[type]/index.tsx Co-authored-by: Omar López <[email protected]> * Update apps/web/pages/v2/event-types/[type]/index.tsx Co-authored-by: Omar López <[email protected]> * Change back to undefined as it is working for sean. See if it fails on testapp * Fixing test builder Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: Jeroen Reumkens <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Omar López <[email protected]> Co-authored-by: Leo Giovanetti <[email protected]>
This commit is contained in:
22 files changed
+551
-20
No files matched your search
@@ -5,6 +5,7 @@ import { z } from "zod";
|
||||
import getAppKeysFromSlug from "@calcom/app-store/_utils/getAppKeysFromSlug";
|
||||
import { DailyLocationType } from "@calcom/app-store/locations";
|
||||
import { stripeDataSchema } from "@calcom/app-store/stripepayment/lib/server";
|
||||
import { validateBookingLimitOrder } from "@calcom/lib";
|
||||
import { _DestinationCalendarModel, _EventTypeCustomInputModel, _EventTypeModel } from "@calcom/prisma/zod";
|
||||
import { stringOrNumber } from "@calcom/prisma/zod-utils";
|
||||
import { createEventTypeInput } from "@calcom/prisma/zod/custom/eventtype";
|
||||
@@ -257,6 +258,7 @@ export const eventTypesRouter = createProtectedRouter()
|
||||
schedule,
|
||||
periodType,
|
||||
locations,
|
||||
bookingLimits,
|
||||
destinationCalendar,
|
||||
customInputs,
|
||||
recurringEvent,
|
||||
@@ -296,6 +298,13 @@ export const eventTypesRouter = createProtectedRouter()
|
||||
data.customInputs = handleCustomInputs(customInputs, id);
|
||||
}
|
||||
|
||||
if (bookingLimits) {
|
||||
const isValid = validateBookingLimitOrder(bookingLimits);
|
||||
if (!isValid)
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: "Booking limits must be in ascending order." });
|
||||
data.bookingLimits = bookingLimits;
|
||||
}
|
||||
|
||||
if (schedule) {
|
||||
data.schedule = {
|
||||
connect: {
|
||||
|
||||
@@ -11,6 +11,7 @@ import logger from "@calcom/lib/logger";
|
||||
import { performance } from "@calcom/lib/server/perfObserver";
|
||||
import getTimeSlots from "@calcom/lib/slots";
|
||||
import prisma, { availabilityUserSelect } from "@calcom/prisma";
|
||||
import { EventBusyDate } from "@calcom/types/Calendar";
|
||||
import { TimeRange } from "@calcom/types/schedule";
|
||||
|
||||
import { TRPCError } from "@trpc/server";
|
||||
@@ -53,7 +54,7 @@ const checkIfIsAvailable = ({
|
||||
currentSeats,
|
||||
}: {
|
||||
time: Dayjs;
|
||||
busy: (TimeRange | { start: string; end: string })[];
|
||||
busy: (TimeRange | { start: string; end: string } | EventBusyDate)[];
|
||||
eventLength: number;
|
||||
beforeBufferTime: number;
|
||||
currentSeats?: CurrentSeats;
|
||||
@@ -118,6 +119,7 @@ async function getEventType(ctx: { prisma: typeof prisma }, input: z.infer<typeo
|
||||
slotInterval: true,
|
||||
beforeEventBuffer: true,
|
||||
afterEventBuffer: true,
|
||||
bookingLimits: true,
|
||||
schedulingType: true,
|
||||
periodType: true,
|
||||
periodStartDate: true,
|
||||
|
||||
Reference in new issue
Block a user