diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index ec911a0210912f..2653ac698d0b16 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -1525,7 +1525,7 @@ "workflow_example_4": "Send email reminder 1 hour before events starts to attendee", "workflow_example_5": "Send custom email when event is rescheduled to host", "workflow_example_6": "Send custom SMS when new event is booked to host", - "count_managed_to_limit": "Count bookings from managed event types", + "count_managed_to_limit": "Include booking counts from managed event types", "welcome_to_cal_header": "Welcome to {{appName}}!", "edit_form_later_subtitle": "You’ll be able to edit this later.", "connect_calendar_later": "I'll connect my calendar later", diff --git a/packages/core/bookingLimits/getBusyTimesFromLimits.ts b/packages/core/bookingLimits/getBusyTimesFromLimits.ts index 209af2b0ccbe05..2053d33bbff3bc 100644 --- a/packages/core/bookingLimits/getBusyTimesFromLimits.ts +++ b/packages/core/bookingLimits/getBusyTimesFromLimits.ts @@ -27,7 +27,7 @@ const _getBusyTimesFromLimits = async ( duration: number | undefined, eventType: NonNullable, bookings: EventBusyDetails[], - timeZone?: string | null, + timeZone: string, rescheduleUid?: string ) => { performance.mark("limitsStart"); @@ -240,8 +240,8 @@ const _getBusyTimesFromTeamLimits = async ( dateTo: Dayjs, teamId: number, includeManagedEvents: boolean, - rescheduleUid?: string, - timeZone?: string | null + timeZone: string, + rescheduleUid?: string ) => { const { limitDateFrom, limitDateTo } = getStartEndDateforLimitCheck( dateFrom.toISOString(), diff --git a/packages/core/getUserAvailability.ts b/packages/core/getUserAvailability.ts index f7f00dc782a9b4..4562bb90080148 100644 --- a/packages/core/getUserAvailability.ts +++ b/packages/core/getUserAvailability.ts @@ -298,8 +298,8 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA duration, eventType, initialData?.busyTimesFromLimitsBookings ?? [], - initialData?.rescheduleUid ?? undefined, - timeZone + timeZone, + initialData?.rescheduleUid ?? undefined ) : []; @@ -318,8 +318,8 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA dateTo.tz(timeZone), teamForBookingLimits.id, teamForBookingLimits.includeManagedEventsInLimits, - initialData?.rescheduleUid ?? undefined, - timeZone + timeZone, + initialData?.rescheduleUid ?? undefined ) : []; diff --git a/packages/features/bookings/lib/handleNewBooking/global-booking-limits.test.ts b/packages/features/bookings/lib/handleNewBooking/global-booking-limits.test.ts index 69f3c1efa4b3f5..c37181e28d81bb 100644 --- a/packages/features/bookings/lib/handleNewBooking/global-booking-limits.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/global-booking-limits.test.ts @@ -160,7 +160,7 @@ describe( }) ); - const mockBookingData1 = getMockRequestDataForBooking({ + const mockBookingWithinLimit = getMockRequestDataForBooking({ data: { start: `2024-08-08T04:00:00.000Z`, end: `2024-08-08T04:30:00.000Z`, @@ -175,7 +175,7 @@ describe( const { req: req1 } = createMockNextJsRequest({ method: "POST", - body: mockBookingData1, + body: mockBookingWithinLimit, }); const createdBooking = await handleNewBooking(req1); @@ -187,7 +187,7 @@ describe( }) ); - const mockBookingData2 = getMockRequestDataForBooking({ + const mockBookingAboveLimit = getMockRequestDataForBooking({ data: { start: `2024-08-08T04:00:00.000Z`, end: `2024-08-08T04:30:00.000Z`, @@ -202,10 +202,10 @@ describe( const { req: req2 } = createMockNextJsRequest({ method: "POST", - body: mockBookingData2, + body: mockBookingAboveLimit, }); - // this is the thrid team booking of this week for user 101, limit reached + // this is the third team booking of this week for user 101, limit reached await expect(async () => await handleNewBooking(req2)).rejects.toThrowError( "no_available_users_found_error" ); @@ -251,7 +251,7 @@ describe( }) ); - const mockBookingData1 = getMockRequestDataForBooking({ + const mockBookingWithinLimit = getMockRequestDataForBooking({ data: { start: `2024-08-07T04:30:00.000Z`, end: `2024-08-07T05:00:00.000Z`, @@ -266,7 +266,7 @@ describe( const { req: req1 } = createMockNextJsRequest({ method: "POST", - body: mockBookingData1, + body: mockBookingWithinLimit, }); const createdBooking = await handleNewBooking(req1); @@ -278,7 +278,7 @@ describe( }) ); - const mockBookingData2 = getMockRequestDataForBooking({ + const mockBookingAboveLimit = getMockRequestDataForBooking({ data: { start: `2024-08-07T04:00:00.000Z`, end: `2024-08-07T04:30:00.000Z`, @@ -293,7 +293,7 @@ describe( const { req: req2 } = createMockNextJsRequest({ method: "POST", - body: mockBookingData1, + body: mockBookingAboveLimit, }); // this is the second team booking of this day for user 101, limit reached @@ -387,7 +387,7 @@ describe( }) ); - const mockBookingData1 = getMockRequestDataForBooking({ + const mockBookingWithinLimit = getMockRequestDataForBooking({ data: { start: `2024-08-29T04:30:00.000Z`, end: `2024-08-29T05:00:00.000Z`, @@ -402,7 +402,7 @@ describe( const { req: req1 } = createMockNextJsRequest({ method: "POST", - body: mockBookingData1, + body: mockBookingWithinLimit, }); const createdBooking = await handleNewBooking(req1); @@ -414,7 +414,7 @@ describe( }) ); - const mockBookingData2 = getMockRequestDataForBooking({ + const mockBookingAboveLimit = getMockRequestDataForBooking({ data: { start: `2024-08-25T04:00:00.000Z`, end: `2024-08-25T04:30:00.000Z`, @@ -429,7 +429,7 @@ describe( const { req: req2 } = createMockNextJsRequest({ method: "POST", - body: mockBookingData2, + body: mockBookingAboveLimit, }); // this is the firth team booking (incl. managed) of this month for user 101, limit reached @@ -515,7 +515,7 @@ describe( }) ); - const mockBookingData1 = getMockRequestDataForBooking({ + const mockBookingWithinLimit = getMockRequestDataForBooking({ data: { start: `2024-08-29T04:30:00.000Z`, end: `2024-08-29T05:00:00.000Z`, @@ -530,7 +530,7 @@ describe( const { req: req1 } = createMockNextJsRequest({ method: "POST", - body: mockBookingData1, + body: mockBookingWithinLimit, }); const createdBooking = await handleNewBooking(req1); @@ -542,7 +542,7 @@ describe( }) ); - const mockBookingData2 = getMockRequestDataForBooking({ + const mockBookingAboveLimit = getMockRequestDataForBooking({ data: { start: `2024-11-25T04:00:00.000Z`, end: `2024-11-25T04:30:00.000Z`, @@ -557,7 +557,7 @@ describe( const { req: req2 } = createMockNextJsRequest({ method: "POST", - body: mockBookingData2, + body: mockBookingAboveLimit, }); await expect(async () => await handleNewBooking(req2)).rejects.toThrowError( diff --git a/packages/lib/server/checkBookingLimits.ts b/packages/lib/server/checkBookingLimits.ts index bce82ee8386b2c..ff951d5ee6ef00 100644 --- a/packages/lib/server/checkBookingLimits.ts +++ b/packages/lib/server/checkBookingLimits.ts @@ -79,7 +79,7 @@ export async function checkBookingLimit({ teamId, startDate: startDate, endDate: endDate, - returnCount: true, + shouldReturnCount: true, excludedUid: rescheduleUid, includeManagedEvents, }); diff --git a/packages/lib/server/repository/booking.ts b/packages/lib/server/repository/booking.ts index f5d03194be19e0..27713f7d1e71d3 100644 --- a/packages/lib/server/repository/booking.ts +++ b/packages/lib/server/repository/booking.ts @@ -13,11 +13,11 @@ type TeamBookingsParamsBase = { endDate: Date; excludedUid?: string | null; includeManagedEvents: boolean; - returnCount?: boolean; + shouldReturnCount?: boolean; }; type TeamBookingsParamsWithCount = TeamBookingsParamsBase & { - returnCount: true; + shouldReturnCount: true; }; type TeamBookingsParamsWithoutCount = TeamBookingsParamsBase; @@ -274,7 +274,7 @@ export class BookingRepository { ): Promise>; static async getAllAcceptedTeamBookingsOfUser(params: TeamBookingsParamsBase) { - const { user, teamId, startDate, endDate, excludedUid, returnCount, includeManagedEvents } = params; + const { user, teamId, startDate, endDate, excludedUid, shouldReturnCount, includeManagedEvents } = params; const baseWhere: Prisma.BookingWhereInput = { status: BookingStatus.ACCEPTED, @@ -321,7 +321,7 @@ export class BookingRepository { }, }; - if (returnCount) { + if (shouldReturnCount) { const collectiveRoundRobinBookingsOwner = await prisma.booking.count({ where: whereCollectiveRoundRobinOwner, });