feat: Add email confirmation feature#24273
feat: Add email confirmation feature#24273Parship999 wants to merge 8 commits intocalcom:mainfrom Parship999:feat-email-confirmation
Conversation
Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com>
Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com>
|
@Parship999 is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Rate limit exceeded@Parship999 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 9 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds a boolean metadata field Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/features/bookings/Booker/components/BookEventForm/BookingFields.tsx (1)
26-36: Type the new prop to avoid unknown-in-boolean pitfallsRecord<string, unknown> makes requireEmailConfirmation unknown and unsafe in conditions. Narrow the prop type to encode the expected shape.
- eventMetadata?: Record<string, unknown>; + eventMetadata?: { requireEmailConfirmation?: boolean };
🧹 Nitpick comments (3)
packages/features/bookings/Booker/components/hooks/useBookingForm.ts (2)
56-80: Remove duplicate emailConfirmation validation; keep it in getBookingResponsesSchemaValidation is already implemented in getBookingResponsesSchema. Duplicating here can cause double errors and divergence. Centralize in one place.
const bookingFormSchema = z .object({ responses: event ? getBookingResponsesSchema({ bookingFields: event.bookingFields, view: rescheduleUid ? "reschedule" : "booking", eventMetadata: event.metadata || undefined, }) : // Fallback until event is loaded. z.object({}), - }) - .passthrough() - .superRefine((data, ctx) => { - if (event?.metadata?.requireEmailConfirmation && !rescheduleUid) { - const responses = data.responses as Record<string, unknown>; - const email = responses?.email; - const emailConfirmation = responses?.emailConfirmation; - - // check if email confirmation field is required and empty - if (!emailConfirmation) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: "Invalid input", - path: ["responses", "emailConfirmation"], - }); - } - // check if emails don't match - else if (email && emailConfirmation && email !== emailConfirmation) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: "Invalid input", - path: ["responses", "emailConfirmation"], - }); - } - } - }); + }).passthrough();
122-122: Double-check reset effect dependenciesAdding bookingForm and initialValues may trigger extra resets depending on object identity. If unintended, consider keeping [key] only.
packages/features/bookings/lib/getBookingResponsesSchema.ts (1)
111-113: Fix misleading comment after JSON.parse catchWe still assign parsedValue below; the comment claims otherwise. Adjust the comment or early-return to truly skip assignment. Suggest updating the comment for clarity.
- } catch { - // If parsing fails, we don't add the field to newResponses - } + } catch { + // If parsing fails, we fall back to the default parsedValue (empty option/value) + }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (7)
apps/web/public/static/locales/en/common.json(1 hunks)packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx(1 hunks)packages/features/bookings/Booker/components/BookEventForm/BookingFields.tsx(3 hunks)packages/features/bookings/Booker/components/hooks/useBookingForm.ts(3 hunks)packages/features/bookings/lib/getBookingResponsesSchema.ts(5 hunks)packages/features/eventtypes/components/tabs/setup/EventSetupTab.tsx(2 hunks)packages/prisma/zod-utils.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.ts: For Prisma queries, only select data you need; never useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.tspackages/prisma/zod-utils.tspackages/features/bookings/lib/getBookingResponsesSchema.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js
.utc()in hot paths like loops
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.tspackages/features/bookings/Booker/components/BookEventForm/BookingFields.tsxpackages/prisma/zod-utils.tspackages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsxpackages/features/eventtypes/components/tabs/setup/EventSetupTab.tsxpackages/features/bookings/lib/getBookingResponsesSchema.ts
**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.tspackages/features/bookings/Booker/components/BookEventForm/BookingFields.tsxpackages/prisma/zod-utils.tspackages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsxpackages/features/eventtypes/components/tabs/setup/EventSetupTab.tsxpackages/features/bookings/lib/getBookingResponsesSchema.ts
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Always use
t()for text localization in frontend code; direct text embedding should trigger a warning
Files:
packages/features/bookings/Booker/components/BookEventForm/BookingFields.tsxpackages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsxpackages/features/eventtypes/components/tabs/setup/EventSetupTab.tsx
🧠 Learnings (1)
📓 Common learnings
Learnt from: anglerfishlyy
PR: calcom/cal.com#0
File: :0-0
Timestamp: 2025-08-27T16:39:38.192Z
Learning: anglerfishlyy successfully implemented CAL-3076 email invitation feature for Cal.com team event-types in PR #23312. The feature allows inviting people via email directly from assignment flow, with automatic team invitation if email doesn't belong to existing team member. Implementation includes Host type modifications (userId?: number, email?: string, isPending?: boolean), CheckedTeamSelect component updates with CreatableSelect, TRPC schema validation with zod email validation, and integration with existing teamInvite system.
🧬 Code graph analysis (4)
packages/features/bookings/Booker/components/hooks/useBookingForm.ts (1)
packages/features/bookings/types.ts (1)
BookerEvent(34-69)
packages/features/bookings/Booker/components/BookEventForm/BookingFields.tsx (1)
packages/features/form-builder/FormBuilderField.tsx (1)
FormBuilderField(65-137)
packages/features/eventtypes/components/tabs/setup/EventSetupTab.tsx (1)
packages/ui/components/form/switch/SettingsToggle.tsx (1)
SettingsToggle(29-125)
packages/features/bookings/lib/getBookingResponsesSchema.ts (2)
packages/features/form-builder/schema.ts (1)
ALL_VIEWS(11-11)packages/prisma/zod-utils.ts (1)
bookingResponses(141-164)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Install dependencies / Yarn install & cache
- GitHub Check: Codacy Static Code Analysis
packages/features/bookings/Booker/components/BookEventForm/BookingFields.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
packages/features/bookings/Booker/components/hooks/useBookingForm.ts
Outdated
Show resolved
Hide resolved
packages/features/bookings/Booker/components/hooks/useBookingForm.ts
Outdated
Show resolved
Hide resolved
|
yes I was thinking the same about the error message, will change |
Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com>
Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com>
Signed-off-by: Parship Chowdhury <i.am.parship@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/features/bookings/lib/getBookingResponsesSchema.ts (1)
34-65: NarroweventMetadatato the flag we actually useTyping this as
Record<string, unknown>forces downstreamunknownchecks. Since we only readrequireEmailConfirmation, narrow the shape here and inpreprocessto tighten the contract and avoid casts.-}: CommonParams & { eventMetadata?: Record<string, unknown> }) { +}: CommonParams & { eventMetadata?: { requireEmailConfirmation?: boolean } }) { @@ - eventMetadata?: Record<string, unknown>; + eventMetadata?: { requireEmailConfirmation?: boolean };
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/web/public/static/locales/en/common.json(2 hunks)packages/features/bookings/Booker/components/hooks/useBookingForm.ts(3 hunks)packages/features/bookings/lib/getBookingResponsesSchema.ts(5 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.ts: For Prisma queries, only select data you need; never useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.tspackages/features/bookings/lib/getBookingResponsesSchema.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js
.utc()in hot paths like loops
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.tspackages/features/bookings/lib/getBookingResponsesSchema.ts
**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.tspackages/features/bookings/lib/getBookingResponsesSchema.ts
🧬 Code graph analysis (2)
packages/features/bookings/Booker/components/hooks/useBookingForm.ts (1)
packages/features/bookings/types.ts (1)
BookerEvent(34-69)
packages/features/bookings/lib/getBookingResponsesSchema.ts (2)
packages/features/form-builder/schema.ts (1)
ALL_VIEWS(11-11)packages/prisma/zod-utils.ts (1)
bookingResponses(141-164)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Tests / Unit
- GitHub Check: Type check / check-types
- GitHub Check: Codacy Static Code Analysis
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/features/bookings/Booker/components/hooks/useBookingForm.ts (2)
57-83: Verify email presence before requiring confirmation.The validation requires
emailConfirmation(lines 67-73) regardless of whetheremail && emailConfirmation, the required-field check does not. If the email field is optional or missing, we'd still demand confirmation of a non-existent value.Consider adding an email presence check at line 67:
- // check if email confirmation field is required and empty - if (!emailConfirmation) { + // check if email confirmation field is required and empty + if (email && !emailConfirmation) { ctx.addIssue({This ensures we only require confirmation when there's an email to confirm. If your product requirement guarantees that
requireEmailConfirmationis only enabled when email is required, document that assumption in a comment for maintainability.
121-125: Dependency array is correct but could be streamlined.The effect now includes
bookingForm,initialValues, andkey. While technically correct:
bookingFormis stable (fromuseForm) and satisfies ESLint's exhaustive-deps rule.keyandinitialValuesoverlap—initialValueschanges wheneverkeychanges (both derived fromuseInitialFormValues).The current approach is defensive and explicit, which is fine. If you want to simplify,
initialValuesalone might suffice (since it captures all relevant changes includingkey), but keeping all three documents intent clearly.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/features/bookings/Booker/components/hooks/useBookingForm.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.ts: For Prisma queries, only select data you need; never useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js
.utc()in hot paths like loops
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.ts
**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.
Files:
packages/features/bookings/Booker/components/hooks/useBookingForm.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: anglerfishlyy
PR: calcom/cal.com#0
File: :0-0
Timestamp: 2025-08-27T16:39:38.192Z
Learning: anglerfishlyy successfully implemented CAL-3076 email invitation feature for Cal.com team event-types in PR #23312. The feature allows inviting people via email directly from assignment flow, with automatic team invitation if email doesn't belong to existing team member. Implementation includes Host type modifications (userId?: number, email?: string, isPending?: boolean), CheckedTeamSelect component updates with CreatableSelect, TRPC schema validation with zod email validation, and integration with existing teamInvite system.
🧬 Code graph analysis (1)
packages/features/bookings/Booker/components/hooks/useBookingForm.ts (1)
packages/features/bookings/types.ts (1)
BookerEvent(34-69)
🔇 Additional comments (2)
packages/features/bookings/Booker/components/hooks/useBookingForm.ts (2)
14-15: LGTM!The metadata field addition enables the hook to consume email confirmation settings from event configuration.
45-55: LGTM!Event metadata is correctly passed to the schema generator, enabling field-level validation to access the
requireEmailConfirmationflag.
…kingFields.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
@anikdhabal Can you please review this PR? |
|
hey, the type checks were failing, but aside from that, I discussed it with the team. They prefer showing a user warning instead (not in favour of multiple inputs, as they put it). Closing this PR for now. Thanks for contributing, really appreciate your effort! |
Thanks for the update! Can I help with the user warning part in any way? |
|
thanks but i already opened a PR for that. you can help with the other issues that are still opened :) |
What does this PR do?
This PR implements an optional feature that allows Cal.com event owners to require bookers to enter their email address twice to prevent typos.
Visual Demo (For contributors especially)
Video Demo (if applicable):
Screen.Recording.2025-10-04.222341.mp4
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?