1.4 KiB
1.4 KiB
Groups + Switcher Plan
Focus
Group create/join + group switcher in navbar.
Goals
- Create groups and invite codes.
- Join groups via invite code.
- Persist active group selection per user.
- Enforce server-side group membership checks.
Proposed changes
Database (existing schema)
Use existing tables:
groups,group_members.
Backend
Add routes:
POST /api/groupsto create a group- Body:
{ name } - Creates group, generates invite code, adds creator as GROUP_ADMIN.
- Body:
POST /api/groups/jointo join by invite code- Body:
{ inviteCode } - Adds user as MEMBER if not already in group.
- Body:
GET /api/groupsto list groups for current user- Returns list of groups and roles.
POST /api/groups/activeto set active group- Persists in
user_settingsJSON.
- Persists in
Add server helpers:
getSessionUser()already exists- Add
requireSessionUser()andgetUserGroups(userId)helpers - Add
getActiveGroup(userId)helper
Frontend
- Update navbar to show current group and dropdown of groups.
- Add minimal create/join UI (modal or simple dropdown actions).
Tests
- Add API tests for create/join/list/active group.
Files impacted (expected)
apps/web/app/api/groups/*apps/web/lib/groups.tsapps/web/components/navbar.tsxapps/web/app/page.tsx(use active group)apps/web/__tests__/groups.test.ts
Status
- Implemented
Test output
create group inserts membership