Conversation
… asset index Add teamMembersForForm support to both simple and advanced mode loaders in data.server.ts. This ensures BASE/SELF_SERVICE users always have their team member available in the custodian dropdown when creating bookings from the asset index bulk actions, regardless of pagination settings. Previously, when canSeeAllCustody was true, team members were paginated to 12 items, and the current user's team member might not be in the first page, preventing booking creation. This completes the fix across all booking creation entry points: - Bookings index - Calendar - Asset detail page - Kit detail page - Asset index bulk actions (this change)
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors team member data fetching for booking forms to optimize performance and separate concerns between filter dropdowns and form custodian selects. The key change introduces a new getTeamMemberForForm function that optimizes the query for BASE/SELF_SERVICE users by fetching only their team member in a single query, while ADMIN users continue to get the paginated list.
- Replaces
getTeamMemberForCustodianFilterwithgetTeamMemberForFormin booking form contexts - Introduces conditional data fetching: BASE/SELF_SERVICE users get optimized single queries, ADMIN users reuse filter data
- Adds
teamMembersForFormproperty across multiple routes to maintain backward compatibility and clear separation
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/modules/team-member/service.server.ts | Adds new getTeamMemberForForm function that optimizes team member fetching for forms |
| app/routes/_layout+/bookings.new.tsx | Replaces getTeamMemberForCustodianFilter with getTeamMemberForForm and adds teamMembersForForm property |
| app/routes/_layout+/bookings._index.tsx | Conditionally fetches team members for forms, reusing filter data for ADMIN users |
| app/routes/_layout+/calendar.tsx | Separates filter and form team member fetching with conditional logic for BASE/SELF_SERVICE |
| app/routes/_layout+/assets.$assetId.overview.create-new-booking.tsx | Updates to use getTeamMemberForForm for booking creation |
| app/routes/_layout+/kits.$kitId.assets.create-new-booking.tsx | Updates to use getTeamMemberForForm for kit booking creation |
| app/modules/asset/data.server.ts | Adds conditional team member fetching for both simple and advanced mode loaders |
| app/components/booking/forms/new-booking-form.tsx | Updates to use teamMembersForForm with fallback to teamMembers |
| app/components/booking/forms/fields/custodian.tsx | Changes initialDataKey from teamMembers to teamMembersForForm |
| app/components/booking/create-booking-dialog.tsx | Updates to use teamMembersForForm instead of teamMembers |
Comments suppressed due to low confidence (1)
app/modules/team-member/service.server.ts:576
- Corrected spelling of 'THis' to 'This' and 'doenst' to 'doesn't'.
* Fixes team members with invalid names. THis runs as void on the background so it doenst block the main thread
There was a problem hiding this comment.
💡 Codex Review
The bulk booking dialog on the asset index still derives defaultTeamMember from teamMembers. For BASE/SELF_SERVICE users with canSeeAllCustody, that array is paginated to 12 results and often does not contain the current user—exactly the scenario this change set is meant to solve. Although the loader now returns teamMembersForForm with the guaranteed current team member, the dialog ignores it and therefore still yields undefined defaults and an unusable custodian select. Use teamMembersForForm (or fall back to teamMembers) for the lookup so these users can actually create bookings from the asset index.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
1. Use teamMembersForForm in CreateBookingForSelectedAssetsDialog Previously, the dialog searched the paginated teamMembers array for the default custodian, causing undefined defaults when the user's team member wasn't in the first 12 results. Now uses teamMembersForForm which guarantees the current user's team member is present for BASE/SELF_SERVICE users. 2. Fix totalTeamMembers count in getTeamMemberForForm Changed from hardcoded 1 to teamMember ? 1 : 0 to accurately reflect when no team member is found. This prevents inconsistencies that could affect pagination or UI logic depending on this count. 3. Explicitly pass filterByUserId: false for ADMIN users Made the intent clear by explicitly passing filterByUserId: false when calling getTeamMemberForCustodianFilter for ADMIN users, rather than relying on undefined behavior.
Add
teamMembersForFormsupport to both simple and advanced mode loaders in data.server.ts. This ensures BASE/SELF_SERVICE users always have their team member available in the custodian dropdown when creating bookings from the asset index bulk actions, regardless of pagination settings.Previously, when
canSeeAllCustodywas true, team members were paginated to 12 items, and the current user's team member might not be in the first page, preventing booking creation.This completes the fix across all booking creation entry points: