-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(admin): updated admin routes to consolidate duplicate behavior #2257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryConsolidates duplicate admin routes for managing organization membership and billing. The Key improvements:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Admin
participant MembersAPI as POST /organizations/:id/members
participant Database
participant Membership as addUserToOrganization()
participant Stripe
Admin->>MembersAPI: Add user to org
MembersAPI->>Database: Validate org exists
MembersAPI->>Database: Validate user exists
MembersAPI->>Database: Check existing membership
alt User already in this org
MembersAPI->>Database: Check if role differs
alt Role differs
MembersAPI->>Database: Update member role
MembersAPI-->>Admin: Return 'updated' action
else Role same
MembersAPI-->>Admin: Return 'already_member' action
end
else User in another org
MembersAPI-->>Admin: Error: single-org constraint
else User not in any org
MembersAPI->>Membership: addUserToOrganization()
Membership->>Database: Check seat availability
Membership->>Database: Create member record
alt Org is paid (team/enterprise)
Membership->>Database: Find user's Pro subscription
alt User has active Pro
Membership->>Database: Snapshot Pro usage
Membership->>Database: Mark Pro cancelAtPeriodEnd
Membership-->>MembersAPI: Return with billing actions
end
end
MembersAPI-->>Admin: Return 'created' action
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, no comments
Summary
Type of Change
Testing
Tested manually
Checklist