Skip to content

feat: implement multi-day bookings feature#1

Open
a5m0 wants to merge 3 commits intomainfrom
claude/implement-issue-20441-Q26RY
Open

feat: implement multi-day bookings feature#1
a5m0 wants to merge 3 commits intomainfrom
claude/implement-issue-20441-Q26RY

Conversation

@a5m0
Copy link
Owner

@a5m0 a5m0 commented Jan 7, 2026

This commit implements a basic multi-day booking functionality as requested in issue calcom#20441.

Key Changes:

  • Added multiDayConfig to EventType metadata schema with enabled flag and numberOfDays field (1-30 days)
  • Updated booking validation to handle multi-day durations (numberOfDays * 24 * 60 minutes)
  • Added UI controls in EventSetupTab to enable and configure multi-day bookings
  • Multi-day bookings are mutually exclusive with multiple durations and seat options
  • Added translation keys for multi-day booking UI elements
  • Added MAX_MULTI_DAY_EVENT_DURATION_MINUTES constant (30 days = 43,200 minutes)

Implementation Details:

  • Multi-day bookings store configuration in EventType.metadata.multiDayConfig
  • Duration is automatically calculated as numberOfDays * 24 * 60 minutes
  • Validation updated in validateEventLength to accept multi-day durations
  • UI toggles prevent conflicts between multi-day, multiple durations, and seats features
  • Backward compatible - existing event types are unaffected

This basic implementation addresses the core use cases mentioned in the issue:

  • Car rentals, property rentals, construction work, multi-day training sessions, etc.

Resolves calcom#20441

claude added 3 commits January 7, 2026 19:10
This commit implements a basic multi-day booking functionality as requested in issue calcom#20441.

Key Changes:
- Added multiDayConfig to EventType metadata schema with enabled flag and numberOfDays field (1-30 days)
- Updated booking validation to handle multi-day durations (numberOfDays * 24 * 60 minutes)
- Added UI controls in EventSetupTab to enable and configure multi-day bookings
- Multi-day bookings are mutually exclusive with multiple durations and seat options
- Added translation keys for multi-day booking UI elements
- Added MAX_MULTI_DAY_EVENT_DURATION_MINUTES constant (30 days = 43,200 minutes)

Implementation Details:
- Multi-day bookings store configuration in EventType.metadata.multiDayConfig
- Duration is automatically calculated as numberOfDays * 24 * 60 minutes
- Validation updated in validateEventLength to accept multi-day durations
- UI toggles prevent conflicts between multi-day, multiple durations, and seats features
- Backward compatible - existing event types are unaffected

This basic implementation addresses the core use cases mentioned in the issue:
- Car rentals, property rentals, construction work, multi-day training sessions, etc.

Resolves calcom#20441
This commit addresses code review feedback and improves the multi-day bookings feature:

1. Form State Management:
   - Use formMethods.watch() and useEffect for better form state synchronization
   - Prevents state drift when form is reloaded or remounted

2. Duration Validation & Display:
   - Hide duration input when multi-day is enabled, show calculated duration instead
   - Display human-readable duration: "Duration: N day(s) (X hours)"
   - Import MAX_MULTI_DAY_EVENT_DURATION_MINUTES constant for proper validation

3. Server-Side Validation:
   - Add mutual exclusivity validation in update.handler.ts
   - Prevent multi-day + seats combination on server side
   - Prevent multi-day + multiple durations on server side

4. Form Initialization:
   - Initialize multiDayEnabled and multiDayNumberOfDays fields in useEventTypeForm
   - Extract values from metadata for proper form default values
   - Filter out UI-only fields (multiDayEnabled, multiDayNumberOfDays) in handleSubmit

5. Translation:
   - Add "multi_day_duration_calculated" translation key

These improvements ensure data integrity, better UX, and eliminate edge cases
where state could become inconsistent between UI and form values.
This commit addresses all critical recommendations from the code review:

1. Schema Validation Enhancement:
   - Added .int() constraint to numberOfDays in Zod schema
   - Ensures only integer values are accepted (prevents decimals like 2.5)

2. Recurring Event Conflict Validation:
   - Added server-side validation in update.handler.ts
   - Multi-day bookings cannot coexist with recurring events
   - Added UI-level prevention with disabled toggle and tooltip
   - Added translation key for recurring event conflict message

3. Improved State Synchronization:
   - Removed redundant useState for multi-day configuration
   - Use formMethods.watch() values directly as source of truth
   - Eliminates potential race conditions and state drift
   - Simplified code by removing useEffect synchronization
   - Form values now flow unidirectionally (single source of truth)

4. Comprehensive Test Coverage:
   - Added validateEventLength.test.ts with 15+ test cases
   - Tests single duration, multiple durations, and multi-day modes
   - Added zod-utils.multiday.test.ts with 20+ test cases
   - Tests valid/invalid configurations, boundary values, type validation
   - Tests .int() constraint, min/max constraints, and field requirements

All tests follow vitest patterns and cover:
- Valid configurations (1 day, 30 days, mid-range values)
- Invalid configurations (< 1, > 30, decimals, negative values)
- Missing/incorrect field types
- Priority of multi-day over multiple durations
- Error messages and logging

This ensures data integrity, prevents invalid states, and provides
comprehensive validation at both schema and runtime levels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why Multi-Day Bookings Are Worth Building

2 participants