refactor: pass only required fields to useBookingForm and useBookings hooks#22494
refactor: pass only required fields to useBookingForm and useBookings hooks#22494
Conversation
… hooks - Extract only bookingFields from event.data for useBookingForm hook - Extract only required event properties for useBookings hook based on IUseBookings interface - Reduces memory usage and makes data flow more explicit - Maintains same event structure to avoid breaking hook implementations Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
✅ No security or compliance issues detected. Reviewed everything up to 0e073ab. Security Overview
Detected Code Changes
Reply to this PR with |
E2E results are ready! |
…okingForm and useBookings hooks
Originally by: hbjORbj
# refactor: pass only required fields to useBookingForm and useBookings hooks
## Summary
Refactored the `BookerWebWrapper` component to pass only the required fields to the `useBookingForm` and `useBookings` hooks instead of passing the entire `event` object. This optimization reduces memory usage and makes the data flow more explicit.
**Changes made:**
- **useBookingForm**: Now receives only `{ bookingFields: event.data.bookingFields }` instead of the full `event.data`
- **useBookings**: Now receives a filtered event object containing only the fields specified in the `IUseBookings` interface: `id`, `slug`, `subsetOfHosts`, `requiresConfirmation`, `isDynamic`, `metadata`, `forwardParamsSuccessRedirect`, `successRedirectUrl`, `length`, `recurringEvent`, `schedulingType`, and `subsetOfUsers`
The refactoring maintains the same event structure (with `data` property) to avoid breaking the hook implementations while significantly reducing the amount of data passed between components.
## Review & Testing Checklist for Human
**⚠️ YELLOW RISK** - Moderate risk due to core functionality impact without end-to-end testing
- [ ] **Test the complete booking flow end-to-end** - Create a test booking to ensure no runtime errors occur and all functionality works correctly
- [ ] **Verify hook interfaces match reality** - Check that the `useBookingForm` and `useBookings` hooks don't internally access any event properties beyond what's defined in their interfaces
- [ ] **Check for hidden data dependencies** - Ensure the extracted fields don't have nested references to other parts of the event object that could cause runtime issues
---
### Diagram
```mermaid
%%{ init : { "theme" : "default" }}%%
graph TD
BWW["BookerWebWrapper.tsx<br/>(EDITED)"]:::major-edit
UBF["useBookingForm.ts<br/>(hook interface)"]:::context
UB["useBookings.ts<br/>(hook interface)"]:::context
IUseBookingForm["IUseBookingForm<br/>(interface)"]:::context
IUseBookings["IUseBookings<br/>(interface)"]:::context
BWW -->|"filtered: { bookingFields }"| UBF
BWW -->|"filtered: { id, slug, etc. }"| UB
IUseBookingForm -->|"defines required fields"| UBF
IUseBookings -->|"defines required fields"| UB
subgraph Legend
L1[Major Edit]:::major-edit
L2[Minor Edit]:::minor-edit
L3[Context/No Edit]:::context
end
classDef major-edit fill:#90EE90
classDef minor-edit fill:#ADD8E6
classDef context fill:#FFFFFF
```
### Notes
- **Type checking passed**: All TypeScript checks pass, confirming the filtered data structure matches the hook interfaces
- **Performance improvement**: Reduces memory usage by only passing required fields instead of the entire event object
- **Maintainability**: Makes data dependencies explicit and easier to track
- **Session info**: Requested by benny@cal.com (@hbjORbj) - Session: https://app.devin.ai/sessions/7197f6bb9f0043a8a65d33e61d386c7d
**⚠️ Important**: While the interfaces suggest this refactoring is safe, the booking flow should be tested manually to ensure no hidden dependencies exist between the hooks and the full event object.
…ctor-booker-hook-event-params
|
This PR is being marked as stale due to inactivity. |
…ctor-booker-hook-event-params
|
This PR is being marked as stale due to inactivity. |
refactor: pass only required fields to useBookingForm and useBookings hooks
Summary
Refactored the
BookerWebWrappercomponent to pass only the required fields to theuseBookingFormanduseBookingshooks instead of passing the entireeventobject. This optimization reduces memory usage and makes the data flow more explicit.Changes made:
{ bookingFields: event.data.bookingFields }instead of the fullevent.dataIUseBookingsinterface:id,slug,subsetOfHosts,requiresConfirmation,isDynamic,metadata,forwardParamsSuccessRedirect,successRedirectUrl,length,recurringEvent,schedulingType, andsubsetOfUsersThe refactoring maintains the same event structure (with
dataproperty) to avoid breaking the hook implementations while significantly reducing the amount of data passed between components.Review & Testing Checklist for Human
useBookingFormanduseBookingshooks don't internally access any event properties beyond what's defined in their interfacesDiagram
%%{ init : { "theme" : "default" }}%% graph TD BWW["BookerWebWrapper.tsx<br/>(EDITED)"]:::major-edit UBF["useBookingForm.ts<br/>(hook interface)"]:::context UB["useBookings.ts<br/>(hook interface)"]:::context IUseBookingForm["IUseBookingForm<br/>(interface)"]:::context IUseBookings["IUseBookings<br/>(interface)"]:::context BWW -->|"filtered: { bookingFields }"| UBF BWW -->|"filtered: { id, slug, etc. }"| UB IUseBookingForm -->|"defines required fields"| UBF IUseBookings -->|"defines required fields"| UB subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#ADD8E6 classDef context fill:#FFFFFFNotes