Enhance booking slot validation and timezone handling#9
Enhance booking slot validation and timezone handling#9ShashankFC wants to merge 2 commits intomainfrom
Conversation
- Enhanced timezone handling for edge cases - Improved slot validation logic - Optimized reservation interval timing - Added better edge case handling for empty slot arrays
…alidation utilities
Entelligence AI Vulnerability ScannerStatus: No security vulnerabilities found Your code passed our comprehensive security analysis. Analyzed 4 files in total |
Review Summary❌ Rejected Comments (1)
🏷️ Draft Comments (6)
|
🔬 Multi-Approach Review SummaryThis PR was reviewed by 2 different approaches for comparison:
Total: 1 review comments Each comment is labeled with its source approach. This allows you to compare different AI review strategies. 🔒 Security Scan: Run once and shared across all approaches for efficiency. WalkthroughThis PR enhances the booking slot validation system with new utility functions while introducing a critical bug and documenting existing issues. A new validation module provides three functions for checking slot time ranges, duration constraints, and business hours compliance. The slot reservation refresh mechanism contains a severe timing bug where the interval calculation was incorrectly converted from milliseconds to seconds, changing refresh timing from ~14 minutes to ~16 hours. Additional improvements include enhanced ISO format validation with null checks and seconds validation, refactored optional chaining for cleaner code, improved logging levels, and documentation of a potential bug in empty slot array handling. Changes
Sequence DiagramThis diagram shows the interactions between components: sequenceDiagram
participant Component
participant useEffect
participant Timer
participant ReservationHandler as handleReserveSlot
Note over Component,ReservationHandler: Component Mount & Initialization
Component->>useEffect: Mount component
activate useEffect
useEffect->>ReservationHandler: handleReserveSlot()
activate ReservationHandler
ReservationHandler-->>useEffect: Reserve slot
deactivate ReservationHandler
Note over useEffect,Timer: BUG: Interval calculation error<br/>Changed from ms to seconds incorrectly<br/>Should be: MINUTES_TO_BOOK * 60 * 1000 - 2000<br/>Actual: MINUTES_TO_BOOK * 60 - 2
useEffect->>Timer: setInterval(callback, interval)
activate Timer
Note right of Timer: Interval runs every<br/>~16 hours (buggy)<br/>instead of ~14 minutes
loop Every interval period
Timer->>ReservationHandler: handleReserveSlot()
activate ReservationHandler
ReservationHandler-->>Timer: Refresh reservation
deactivate ReservationHandler
end
deactivate useEffect
Note over Component,Timer: Component Unmount & Cleanup
Component->>useEffect: Unmount component
activate useEffect
useEffect->>Timer: clearInterval()
deactivate Timer
useEffect->>ReservationHandler: handleRemoveSlot()
activate ReservationHandler
ReservationHandler-->>useEffect: Remove slot
deactivate ReservationHandler
deactivate useEffect
🔒 Security Analysis
Note for WindsurfPlease change the default marketplace provider to the following in the windsurf settings:Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts belowEmoji Descriptions:
Interact with the Bot:
Also you can trigger various commands with the bot by doing The current supported commands are
More commands to be added soon. |
| const interval = setInterval(() => { | ||
| handleReserveSlot(); | ||
| }, parseInt(MINUTES_TO_BOOK) * 60 * 1000 - 2000); | ||
| }, parseInt(MINUTES_TO_BOOK) * 60 - 2); |
There was a problem hiding this comment.
correctness: 🟢 [Standard Reviewer] setInterval interval calculation is incorrect: it uses seconds instead of milliseconds, causing the reservation refresh to occur every ~16 hours instead of every 14 minutes.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In packages/features/bookings/Booker/components/hooks/useSlots.ts, lines 148-150, the interval for setInterval is calculated in seconds instead of milliseconds, causing the reservation refresh to happen every ~16 hours instead of every 14 minutes. Update the interval calculation to use milliseconds: change `parseInt(MINUTES_TO_BOOK) * 60 - 2` to `parseInt(MINUTES_TO_BOOK) * 60 * 1000 - 2000`.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| const interval = setInterval(() => { | |
| handleReserveSlot(); | |
| }, parseInt(MINUTES_TO_BOOK) * 60 * 1000 - 2000); | |
| }, parseInt(MINUTES_TO_BOOK) * 60 - 2); | |
| const interval = setInterval(() => { | |
| handleReserveSlot(); | |
| }, parseInt(MINUTES_TO_BOOK) * 60 * 1000 - 2000); |
This PR improves booking validation by adding better timezone offset handling and comprehensive slot validation utilities. Includes improved ISO format validation and business hours checking.
EntelligenceAI PR Summary
This PR adds booking slot validation utilities and improves code quality while introducing a critical timing bug in the reservation refresh mechanism.
useSlots.tsrefresh interval, breaking reservation timing (BUG B)validateBookingSlot.tswith three validation functions for time range, duration (5-480 min default), and business hoursisValidISOFormatwith null checks and seconds separator validation inisSlotEquivalent.tsisTimeslotAvailable.ts; upgraded logging toconsole.warn