Conversation
… auto-delete empty teams
|
btw some of the changes are from HMTV2-8 as it is not closed yet and since i built off this branch. |
| return team; | ||
| }), | ||
|
|
||
| join: protectedProcedure |
There was a problem hiding this comment.
NEW (HMTV2-9): join mutation. Users join existing team via 4-char team code. Validates one-team-per-user constraint
| .toUpperCase() | ||
| }) | ||
| ) | ||
| .mutation(async ({ ctx, input }) => { |
There was a problem hiding this comment.
validates user not already on team, finds team by code, adds as MEMBER
| return team; | ||
| }), | ||
|
|
||
| invite: protectedProcedure |
There was a problem hiding this comment.
NEW (HMTV2-9): invite mutation. Team owners send email invitations with 7-day expiry. Checks: user is owner, invited email exists/not on team, no duplicate pending invite
| email: z.string().email("Invalid email address") | ||
| }) | ||
| ) | ||
| .mutation(async ({ ctx, input }) => { |
There was a problem hiding this comment.
validates ownership, creates invitation record with expiry
| return newInvitation; | ||
| }), | ||
|
|
||
| acceptInvite: protectedProcedure |
There was a problem hiding this comment.
NEW (HMTV2-9): acceptInvite mutation. Invited users accept pending invitations. Validates: email matches current user, invitation not expired, not already on team. Transactional: adds member + marks invitation as accepted.
| invitationId: z.string() | ||
| }) | ||
| ) | ||
| .mutation(async ({ ctx, input }) => { |
There was a problem hiding this comment.
validates invitation ownership & expiry, adds member, updates invitation
| return { success: true }; | ||
| }), | ||
|
|
||
| leave: protectedProcedure.mutation(async ({ ctx }) => { |
There was a problem hiding this comment.
NEW (HMTV2-9 or HMTV2-10): leave mutation. Users leave team; auto-deletes empty teams + their pending invitations. It removes member, cleans up team if no members remain. Had this code before last week's meeting so I just kept it here. Will probably continue this portion for HMTV2-10. Or just use this PR to complete HMTV2-10-leave-team.
Implements team member invitation system for HMTV2-9.
Features:
joinmutation -> users join a team using a 4-char team codeinvitemutation -> team owners invite users by email (7-day expiry)acceptInvitemutation -> invited users accept pending invitationsleavemutation -> users leave; empty teams auto-deleteteamCodefield,MEMBER_ROLESconstant, transaction safetyFiles changed:
teams.ts,auth-schema.ts,types.ts