Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
adf661c to
00b43a7
Compare
| reqBodyRescheduleUid?: string; | ||
| }; | ||
|
|
||
| export const checkBookingAndDurationLimits = async ({ |
There was a problem hiding this comment.
check both booking and duration limits.
| safeStringify({ | ||
| users: users.map(getPiiFreeUser), | ||
| }) | ||
| await validateBookingTimeIsNotOutOfBounds<typeof eventType>( |
There was a problem hiding this comment.
moved validation code
| const eventType = await getEventType({ | ||
| eventTypeId: req.body.eventTypeId, | ||
| eventTypeSlug: req.body.eventTypeSlug, | ||
| }); |
There was a problem hiding this comment.
it's just more simpler to read.
| export function getCustomInputsResponses( | ||
| reqBody: RequestBody, | ||
| eventTypeCustomInputs: getEventTypeResponse["customInputs"] | ||
| ): NonNullable<CalendarEvent["customInputs"]> { | ||
| if (reqBody.customInputs && reqBody.customInputs.length > 0) { | ||
| return mapCustomInputs(reqBody.customInputs); | ||
| } | ||
|
|
||
| const responses = reqBody.responses || {}; | ||
| return mapResponsesToCustomInputs(responses, eventTypeCustomInputs); |
There was a problem hiding this comment.
refactored this function
| return Object.entries(responses).reduce((acc, [fieldName, fieldValue]) => { | ||
| const foundInput = eventTypeCustomInputs.find((input) => slugify(input.label) === fieldName); | ||
| if (foundInput) { | ||
| acc[foundInput.label] = fieldValue; | ||
| } | ||
| return acc; | ||
| }, {} as NonNullable<CalendarEvent["customInputs"]>); | ||
| } |
There was a problem hiding this comment.
use .reduce method instead of for loop
| throw new HttpError({ statusCode: 403, message: ErrorCode.CancelledBookingsCannotBeRescheduled }); | ||
| } | ||
| } | ||
| let originalRescheduledBooking = originalBooking; |
There was a problem hiding this comment.
I have used let here because it originalRescheduledBooking is re assigned
There was a problem hiding this comment.
It looks like this function is doing two things either getting the rescheduled booking or getting the seated booking. I think if we're going to abstract this logic it should be split into two functions that each havea single purpose.
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (07/10/24)1 reviewer was added to this PR based on Keith Williams's automation. "Add foundation team as reviewer" took an action on this PR • (09/19/24)1 reviewer was added to this PR based on Keith Williams's automation. |
|
To be merged after "booking with phone number" |
joeauyeung
left a comment
There was a problem hiding this comment.
Feedback is addressed. Great refactoring @Udit-takkar
8be4088 to
074b0b2
Compare
|
@joeauyeung fixed merge conflicts |
joeauyeung
left a comment
There was a problem hiding this comment.
Approving again after fixing merge conflicts
What does this PR do?
Continuing refactor of handleNewBooking
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?