Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| import { useMutation } from "react-query"; | ||
| import { Frequency as RRuleFrequency } from "rrule"; | ||
|
|
||
| import { parseRecurringEvent } from "@calcom/lib"; |
There was a problem hiding this comment.
Runtime and type safety for an unknown object
| export function isRecurringEvent(obj: unknown): obj is RecurringEvent { | ||
| const parsedRecuEvt = recurringEventSchema.safeParse(obj); | ||
| return parsedRecuEvt.success; | ||
| } | ||
|
|
||
| export function parseRecurringEvent(obj: unknown): RecurringEvent | null { | ||
| let recurringEvent: RecurringEvent | null = null; | ||
| if (isRecurringEvent(obj)) recurringEvent = obj; | ||
| return recurringEvent; | ||
| } |
There was a problem hiding this comment.
This way we ensure the returned data from the DB is valid or null
|
Can you please test the frontend flow and forms an make it mergable if necessary? @leog |
| `${RRuleFrequency[booking.eventType.recurringEvent.freq] | ||
| .toString() | ||
| .toLowerCase()}`, | ||
| `${Frequency[booking.eventType.recurringEvent.freq].toString().toLowerCase()}`, |
There was a problem hiding this comment.
This piece of very long and repeated string throughout the app will be refactored in an util as part of #2750
| const [recurringEventFrequency, setRecurringEventFrequency] = useState( | ||
| recurringEvent?.freq || RRuleFrequency.WEEKLY | ||
| ); | ||
| const [recurringEventCount, setRecurringEventCount] = useState(recurringEvent?.count || 12); |
There was a problem hiding this comment.
Simplifying the logic to just rely on a state object
| ...recurringEventState, | ||
| interval: parseInt(event?.target.value), | ||
| }; | ||
| formMethods.setValue("recurringEvent", newVal); |
There was a problem hiding this comment.
Controller can be used here to simplify, but not needed - this is already a great PR.
| reqBody.recurringEventId ? (eventType.recurringEvent as RecurringEvent) : {} | ||
| ); | ||
| await sendOrganizerRequestEmail({ ...evt, additionalNotes }); | ||
| await sendAttendeeRequestEmail({ ...evt, additionalNotes }, attendeesList[0]); |
There was a problem hiding this comment.
Out of scope for this PR, but made me think about if do we want to allow the booker (attendee[0] to select a checkbox when booking to notify ALL attendees and not him? Since we ask for emails for all attendees too?

What does this PR do?
TODO:
Parse all these casted values with the zod schema in zod-utils:Environment: Staging(main branch) / Production
Type of change
How should this be tested?
Checklist