fix: improve booking page detection and satisfy explicit type lint#29799
fix: improve booking page detection and satisfy explicit type lint#29799Gunwant35 wants to merge 2 commits into
Conversation
- fix `useIsBookingPage` to detect dynamic public booking pages like `/rick` and `/john+jane` - preserve known booking prefixes and exclude reserved root paths - add explicit `Set<string>` type annotation for `reservedRootPaths` - add regression coverage for booking route detection
|
Welcome to Cal.diy, @Gunwant35! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
📝 WalkthroughWalkthroughRefactors 🚥 Pre-merge checks | ✅ 5✅ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/web/lib/hooks/useIsBookingPage.ts (1)
51-55: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify redundant boolean logic.
Because
isUserBookingTypePagerequiresisUserBookingPageto be true, the conditionisUserBookingPage || isUserBookingTypePageis logically equivalent to justisUserBookingPage. You can safely simplify this block.♻️ Proposed refactor
- const isUserBookingPage = Boolean(searchParams?.get("user")); - const isUserBookingTypePage = isUserBookingPage && Boolean(searchParams?.get("type")); - if (isUserBookingPage || isUserBookingTypePage) { + if (searchParams?.get("user")) { return true; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/lib/hooks/useIsBookingPage.ts` around lines 51 - 55, In the booking-page detection logic, simplify the condition using isUserBookingPage because isUserBookingTypePage already depends on it; remove the redundant OR branch while preserving the existing true return behavior.apps/web/lib/__tests__/useIsBookingPage.test.ts (1)
46-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove duplicate test assertion.
These two assertions are completely identical. You can remove the duplicate line.
♻️ Proposed refactor
expect(isBookingPagePath("/some/page", searchParams)).toBe(true); - expect(isBookingPagePath("/some/page", searchParams)).toBe(true); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/lib/__tests__/useIsBookingPage.test.ts` around lines 46 - 48, Remove the duplicate identical isBookingPagePath assertion in the affected test case, keeping one assertion for the expected true result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/web/lib/__tests__/useIsBookingPage.test.ts`:
- Around line 46-48: Remove the duplicate identical isBookingPagePath assertion
in the affected test case, keeping one assertion for the expected true result.
In `@apps/web/lib/hooks/useIsBookingPage.ts`:
- Around line 51-55: In the booking-page detection logic, simplify the condition
using isUserBookingPage because isUserBookingTypePage already depends on it;
remove the redundant OR branch while preserving the existing true return
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f1573a72-dfc5-4c69-9c1e-33990e3e9bfb
📒 Files selected for processing (2)
apps/web/lib/__tests__/useIsBookingPage.test.tsapps/web/lib/hooks/useIsBookingPage.ts
What does this PR do?
useIsBookingPageto detect dynamic public booking pages like/rickand/john+janeSet<string>type annotation forreservedRootPathsNote: Cal.diy is a community-maintained open-source project. Contributions here do NOT flow to Cal.com's production service. -->
Mandatory Tasks (DO NOT REMOVE)