feat: implement member-based booking limits for organization admins#23413
feat: implement member-based booking limits for organization admins#23413Devanshusharma2005 wants to merge 4 commits intomainfrom
Conversation
- Add bookingLimits Json field to Membership model in Prisma schema - Create database migration for the new bookingLimits field - Update organization updateUser tRPC endpoint to handle bookingLimits - Add booking limits UI to organization member edit sheet using IntervalLimitsManager - Extend booking enforcement logic to check member-level limits in handleNewBooking - Update organization member data fetching to include bookingLimits - Add translation string for booking limits member description - Fix test data to include bookingLimits field Resolves #22626 Co-Authored-By: Devanshu Sharma <devanshusharma658@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
Status, Documentation and Community
|
…mits - Import validateIntervalLimitOrder from intervalLimits library - Add validation logic similar to team booking limits - Ensure booking limits are in ascending order (day ≤ week ≤ month ≤ year) - Throw BAD_REQUEST error with descriptive message for invalid limits This incorporates the key improvement from PR #23233 to maintain consistency with existing team booking limits validation patterns. Co-Authored-By: Devanshu Sharma <devanshusharma658@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
- Remove unused isFormCreateEditAllowed import from formMutation.handler.ts - Remove unused TRPCError import from formQuery.handler.ts - Change MembershipRole from import to type import in permissions.ts These changes were automatically applied by lint-staged during the previous commit. Co-Authored-By: Devanshu Sharma <devanshusharma658@gmail.com>
…ests - Fix validation logic to properly check ascending order of booking limits - Add test coverage for validateIntervalLimitOrder function - Ensure PER_DAY ≤ PER_WEEK ≤ PER_MONTH ≤ PER_YEAR validation works correctly - Handle partial limits (e.g., only PER_DAY and PER_MONTH) properly Co-Authored-By: Devanshu Sharma <devanshusharma658@gmail.com>
What does this PR do?
Implements member-based booking limits controlled by organization admins as described in GitHub issue #22626. This feature allows org admins to set booking limits for individual members that apply across all their event types (both personal and team). The limits are enforced during booking creation and use the existing IntervalLimitsManager UI component.
Key Changes
Database Schema
bookingLimitsJSON field to theMembershiptable to store per-member booking limitsUI Components
/settings/organizations/<slug>/members)IntervalLimitsManagercomponent from event type settingsBackend Implementation
validateIntervalLimitOrdervalidation to ensure limits are in ascending order (day ≤ week ≤ month ≤ year)updateUsertRPC endpoint to save booking limits to membership recordgetUserandlistMembershandlers to include booking limits in responseshandleNewBooking.tsfor team event bookingsHow should this be tested?
Environment Setup
Test Scenarios
Setting Booking Limits:
/settings/organizations/<slug>/membersBooking Enforcement - Team Events:
Validation Testing:
Authorization Testing:
1. Booking Enforcement Completeness
The current implementation only checks member booking limits for team events (
eventType.team?.id). Need to verify if this also needs to apply to personal event types, as the requirements mention "all event types (both personal and team)".2. Type Safety
There are type casts like
organizerMembership.bookingLimits as IntervalLimitthat should be validated for safety.3. Database Migration
The migration adds a nullable JSON column. Verify existing membership records handle this gracefully.
4. Test Coverage
This is a complex feature affecting booking creation but has minimal test additions. Consider if more comprehensive test scenarios are needed.
Mandatory Tasks (DO NOT REMOVE)
Checklist
Link to Devin session: https://app.devin.ai/sessions/10fea31e8ab14a28b8cf010cc3526d68
Requested by: @Devanshusharma2005