Skip to content

Comments

fix: multiple booking duration isn't working#23140

Merged
PeerRich merged 1 commit intocalcom:mainfrom
anikdhabal:booking_duration_issue
Aug 17, 2025
Merged

fix: multiple booking duration isn't working#23140
PeerRich merged 1 commit intocalcom:mainfrom
anikdhabal:booking_duration_issue

Conversation

@anikdhabal
Copy link
Contributor

@anikdhabal anikdhabal commented Aug 17, 2025

What does this PR do?

Fixes:- https://www.loom.com/share/ea091b183a0f46c7bba028c25c6fe1ea?sid=092990d5-32f9-4993-a813-f741a0d9434c

Now:-

60min._.Free.First.Hidden.Example._.Cal.com.and.19.more.pages.-.Personal.-.Microsoft.Edge.2025-08-17.21-36-46.mp4

@vercel
Copy link

vercel bot commented Aug 17, 2025

@anikdhabal is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot requested a review from a team August 17, 2025 16:01
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 17, 2025

Walkthrough

The component Duration.tsx was updated to use a context-based Booker store hook. The import was changed from useBookerStore (from "@calcom/features/bookings/Booker/store") to useBookerStoreContext (from "@calcom/features/bookings/Booker/BookerStoreProvider"). Corresponding hook calls were updated to use useBookerStoreContext for selecting selectedDuration, setSelectedDuration, and state. This reflects a public API shift: the old useBookerStore export is removed in favor of the new useBookerStoreContext provided by the BookerStoreProvider module.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@keithwillcode keithwillcode added the core area: core, team members only label Aug 17, 2025
@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working labels Aug 17, 2025
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
import { useShouldShowArrows } from "@calcom/features/apps/components/AllApps";
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
Copy link
Contributor Author

@anikdhabal anikdhabal Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duration.tsx updates the global store while useSlots.ts reads from context store :-

const selectedDuration = useBookerStoreContext((state) => state.selectedDuration);

This issue is regressed from this pr:- #22925

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might've missed this one, thank you for the fix @anikdhabal! 🐐

@anikdhabal anikdhabal enabled auto-merge (squash) August 17, 2025 16:04
@graphite-app
Copy link

graphite-app bot commented Aug 17, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (08/17/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add ready-for-e2e label" took an action on this PR • (08/17/25)

1 label was added to this PR based on Keith Williams's automation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
packages/features/bookings/components/event-meta/Duration.tsx (6)

48-52: Avoid unnecessary re-renders: add shallow equality

Selecting an array from zustand without an equality function recreates the array each render and can cause extra updates. Use shallow comparator.

Apply this diff in the selected lines:

-  const [selectedDuration, setSelectedDuration, state] = useBookerStoreContext((state) => [
-    state.selectedDuration,
-    state.setSelectedDuration,
-    state.state,
-  ]);
+  const [selectedDuration, setSelectedDuration, state] = useBookerStoreContext(
+    (state) => [state.selectedDuration, state.setSelectedDuration, state.state],
+    shallow
+  );

And add this import at the top of the file:

import { shallow } from "zustand/shallow";

48-52: Clarify naming: avoid shadowing with “state”

state is both the selector param and a string status from the store (state.state). Rename the local variable for readability.

-  const [selectedDuration, setSelectedDuration, state] = useBookerStoreContext(
-    (state) => [state.selectedDuration, state.setSelectedDuration, state.state],
-    shallow
-  );
+  const [selectedDuration, setSelectedDuration, bookerFlowState] = useBookerStoreContext(
+    (state) => [state.selectedDuration, state.setSelectedDuration, state.state],
+    shallow
+  );
@@
-          .filter((dur) => state !== "booking" || dur === selectedDuration)
+          .filter((dur) => bookerFlowState !== "booking" || dur === selectedDuration)

Also applies to: 112-113


114-118: Use a stable key

Using the array index as a key can cause unnecessary remounts if the durations list changes. The duration itself is stable and unique.

-          .map((duration, index) => (
+          .map((duration) => (
@@
-              key={index}
+              key={duration}

100-106: A11y + behavior: add type='button' and accessible labels to navigation buttons

Buttons default to type="submit" and can accidentally submit a wrapping form. Also, add aria-labels and hide decorative icons from AT.

-        <button onClick={handleLeft} className="absolute bottom-0 left-0 flex">
+        <button
+          type="button"
+          onClick={handleLeft}
+          className="absolute bottom-0 left-0 flex"
+          aria-label={t("scroll_left")}
+        >
@@
-            <Icon name="chevron-left" className="text-subtle h-4 w-4" />
+            <Icon name="chevron-left" className="text-subtle h-4 w-4" aria-hidden="true" />
@@
-        <button onClick={handleRight} className="absolute bottom-0 right-0 flex">
+        <button
+          type="button"
+          onClick={handleRight}
+          className="absolute bottom-0 right-0 flex"
+          aria-label={t("scroll_right")}
+        >
@@
-            <Icon name="chevron-right" className="text-subtle h-4 w-4" />
+            <Icon name="chevron-right" className="text-subtle h-4 w-4" aria-hidden="true" />

Note: ensure the i18n keys scroll_left and scroll_right exist (or replace with your project’s standard keys).

Also applies to: 128-135


107-111: Minor: avoid arrow wrapper for onScroll

Passing the handler directly avoids creating a new function on each render.

-        onScroll={(e) => calculateScroll(e)}
+        onScroll={calculateScroll}

115-116: Test id attribute naming consistency

Project conventions typically use data-testid (lowercase id). If that’s the convention here, consider aligning to avoid brittle selectors.

-              data-testId={`multiple-choice-${duration}mins`}
+              data-testid={`multiple-choice-${duration}mins`}

If other tests/components expect data-testId, keep as-is for consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0afe6cf and 86c2c50.

📒 Files selected for processing (1)
  • packages/features/bookings/components/event-meta/Duration.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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/components/event-meta/Duration.tsx
**/*.{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/components/event-meta/Duration.tsx
🧬 Code Graph Analysis (1)
packages/features/bookings/components/event-meta/Duration.tsx (1)
packages/features/bookings/Booker/BookerStoreProvider.tsx (1)
  • useBookerStoreContext (24-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
packages/features/bookings/components/event-meta/Duration.tsx (2)

7-7: Hook migration to useBookerStoreContext looks correct

The import aligns with the new BookerStoreProvider API and is a straightforward, safe swap.


48-52: EventDuration is always wrapped by BookerStoreProvider

I checked all <EventDuration> call sites and their parents:

  • components/event-meta/Duration.tsx → used in components/event-meta/Details.tsx
  • EventDetails (Details.tsx) is imported by Booker/components/EventMeta.tsx
  • EventMeta is only ever rendered inside <BookerStoreProvider> (e.g. in BookerWebWrapper.tsx and BookerPlatformWrapper.tsx)

There are no paths where EventDuration renders outside of a BookerStoreProvider. No changes needed.

@anikdhabal anikdhabal requested a review from emrysal August 17, 2025 16:10
@anikdhabal anikdhabal disabled auto-merge August 17, 2025 16:51
@PeerRich PeerRich enabled auto-merge (squash) August 17, 2025 16:56
@PeerRich PeerRich merged commit 469a942 into calcom:main Aug 17, 2025
98 of 108 checks passed
@github-actions
Copy link
Contributor

E2E results are ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working core area: core, team members only ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants