fix: reschedule issue when limited booking is enabled in the event settings.#23717
fix: reschedule issue when limited booking is enabled in the event settings.#23717anikdhabal merged 10 commits intocalcom:mainfrom
Conversation
WalkthroughAdds a new setter Possibly related PRs
Pre-merge checks (5 passed)✅ Passed checks (5 passed)
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
|
@ShashwatPS is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Actionable comments posted: 0
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/hooks/useBookings.ts (1)
349-359: Remove duplicaterescheduleUidstore update
Drop the directuseBookerStore.setState({ rescheduleUid })call—only invokesetRescheduleUid(error.data?.rescheduleUid)to avoid double updates and extra renders. To prevent transient inconsistentisRescheduling, consider adding a store action that sets bothrescheduleUidandbookingDatatogether atomically.- useBookerStore.setState({ - rescheduleUid: error.data?.rescheduleUid, - }); - setRescheduleUid(error.data?.rescheduleUid); + setRescheduleUid(error.data?.rescheduleUid);
🧹 Nitpick comments (4)
packages/features/bookings/Booker/__tests__/test-utils.tsx (1)
54-55: Make the mock setter mutate state to better reflect real behavior.Right now
setRescheduleUidis a no-opvi.fn(). If tests assert on store state after the error path, they may miss regressions. Mirror the pattern used forsetMonth.- setRescheduleUid: vi.fn(), + setRescheduleUid: vi.fn((uid: string | null) => { + state.rescheduleUid = uid; + }),packages/features/bookings/Booker/components/hooks/useBookings.ts (1)
354-358: Avoid unsafe type coercion; pass a typed shape or relax the setter type.
as unknown as GetBookingTypedefeats type safety and may hide shape mismatches. Either acceptPartial<GetBookingType>in the store setter or construct a properly typed minimal object.Example minimal change (store API):
// store.ts setBookingData: (bookingData: Partial<GetBookingType> | null | undefined) => void;Then remove the
unknown ascast here.packages/features/bookings/Booker/store.ts (2)
140-144: Clarify the docstring to match the field name.“ReferenceID” is vague. Use “Reschedule UID” to align with the state key and domain language.
- /** - * Method used to set ReferenceID - */ + /** + * Set the reschedule UID used during rescheduling flows. + */
300-401: Optional: provide an atomic updater for reschedule context.To prevent intermediate UI states when both
rescheduleUidandbookingDatamust change together, consider a helper likesetRescheduleContext(uid, data)that updates both in a singlesetcall.Example:
// Add to BookerStore setRescheduleContext: (uid: string, data: Partial<GetBookingType>) => void; // In createBookerStore: setRescheduleContext: (uid, data) => { set({ rescheduleUid: uid ?? null, bookingData: (data as GetBookingType) ?? null }); },Then replace the two separate calls in the hook with one.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
packages/features/bookings/Booker/__tests__/test-utils.tsx(1 hunks)packages/features/bookings/Booker/components/hooks/useBookings.ts(2 hunks)packages/features/bookings/Booker/store.ts(2 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/useBookings.tspackages/features/bookings/Booker/store.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/useBookings.tspackages/features/bookings/Booker/store.tspackages/features/bookings/Booker/__tests__/test-utils.tsx
**/*.{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/useBookings.tspackages/features/bookings/Booker/store.tspackages/features/bookings/Booker/__tests__/test-utils.tsx
**/*.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/__tests__/test-utils.tsx
🧠 Learnings (2)
📚 Learning: 2025-08-29T22:57:31.407Z
Learnt from: bandhan-majumder
PR: calcom/cal.com#23454
File: packages/features/bookings/Booker/components/EventMeta.tsx:16-16
Timestamp: 2025-08-29T22:57:31.407Z
Learning: In Cal.com's Booker architecture, components become client-side through BookerStoreProvider.tsx which has "use client". Any component using useBookerStoreContext automatically runs on the client and should use client-appropriate utilities like markdownToSafeHTMLClient, regardless of whether they have explicit "use client" directives.
Applied to files:
packages/features/bookings/Booker/components/hooks/useBookings.ts
📚 Learning: 2025-07-15T12:59:34.389Z
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.389Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
Applied to files:
packages/features/bookings/Booker/components/hooks/useBookings.ts
🧬 Code graph analysis (1)
packages/features/bookings/Booker/components/hooks/useBookings.ts (1)
packages/features/bookings/Booker/BookerStoreProvider.tsx (1)
useBookerStoreContext(24-35)
⏰ 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). (1)
- GitHub Check: Detect changes
🔇 Additional comments (2)
packages/features/bookings/Booker/components/hooks/useBookings.ts (1)
148-150: Good move: consume dedicated setters via context.Selecting
setBookingDataandsetRescheduleUidfrom the store improves cohesion and testability.packages/features/bookings/Booker/store.ts (1)
413-415: Setter implementation looks correct.Normalizing
undefinedtonullavoids tri-state issues and keeps selectors simple.
kart1ka
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for the PR.
E2E results are ready! |
anikdhabal
left a comment
There was a problem hiding this comment.
Don't get the fix. I don’t see in the attached video that you rescheduled a booking
@anikdhabal Actually, a booking was already there for the same event type. I just made another booking for the same event type. The warning that pops up ( attached a ss showing the same ) when I try to make the booking basically shows whether I’m crossing the per-person limit for that event type or not. Then, when I click confirm, it reschedules the last meeting.
|
|
This PR is being marked as stale due to inactivity. |

What does this PR do?
Visual Demo (For contributors especially)
https://www.loom.com/share/f6ccbf8762c44ff89fe0e4f147c39eff?sid=eb19374d-409b-4f74-86ab-6eec60d650fa
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Checklist