Skip to content

Add admin user management API and hooks - #19

Merged
thinkclay merged 1 commit into
mainfrom
codex/create-admin-users-router-with-procedures
Sep 22, 2025
Merged

thinkclay merged 1 commit into
mainfrom
codex/create-admin-users-router-with-procedures

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Summary

  • add an admin users router with role-gated worker search, detail, update, and verification procedures
  • register the admin router in the root tRPC app
  • expose web and native admin user hooks that merge organization context into requests

Testing

  • yarn lint
  • yarn workspace @app/api tsc --noEmit (fails: repo has unresolved module/includes in UI package and duplicate Supabase type identifiers)

https://chatgpt.com/codex/tasks/task_b_68d1dbd2030c833192bb5e2fd19ac49e

@thinkclay
thinkclay merged commit 116aa38 into main Sep 22, 2025
@thinkclay
thinkclay deleted the codex/create-admin-users-router-with-procedures branch September 22, 2025 23:59
thinkclay added a commit that referenced this pull request Feb 11, 2026
## Summary
Completed the final 2 previously-blocked teams files, achieving 100% migration
of all non-analytics team management features from tRPC to SDK.

**Migration Status:** 20 of 20 migratable files (100%) ✅

## SDK Extensions (Final Phase)

### 3. respondToInvitationWithToken() - Public Invitation Endpoint
- Added public (unauthenticated) endpoint for email invitation links
- Accepts token, action, and optional responderId
- Returns status ('accepted' | 'declined') and teamId
- Created React Hook: `useRespondToTeamInvitationWithToken()`

**Types Added:**
- `RespondToInvitationWithTokenParams`
- `RespondToInvitationWithTokenResponse`

**Location:** packages/scaffald-sdk/src/

## File Migrations Completed

### Migration #19: TeamMemberRoleSelect.tsx
**Status:** ✅ Previously completed and committed
- Refactored component interface from `teamMemberId` to `userId`
- Migrated to SDK's `useUpdateTeamMember()` hook
- Updated mutation call structure with nested params
- Updated usage in TeamMembersList.tsx

### Migration #20: accept.tsx (Public Invitation Flow)
**File:** apps/scaffald/app/teams/invitations/accept.tsx
**Changes:**
- Removed tRPC `api.teams.respondToInvitation.useMutation`
- Migrated to SDK's `useRespondToTeamInvitationWithToken()`
- Simplified imports and removed tRPC dependencies
- Maintained full functionality for email invitation acceptance

## Migration Patterns Used

### Public Endpoint Pattern
```typescript
// SDK resource method (no auth required)
async respondToInvitationWithToken(
  params: RespondToInvitationWithTokenParams
): Promise<RespondToInvitationWithTokenResponse>

// React Hook
const mutation = useRespondToTeamInvitationWithToken({
  onSuccess: (result) => {
    if (result.status === 'accepted') {
      // Navigate to team detail page
    }
  }
})

// Usage
await mutation.mutateAsync({
  token,
  action: 'accept',
  responderId: user.id
})
```

## Final Statistics

### Coverage
- **Total Files:** 27
- **Migrated:** 20 (74%)
- **Non-Analytics Coverage:** 20/20 (100%) 🎉

### Not Migrated (By Design)
- 6 Analytics files (intentionally kept in tRPC)
- 1 Mixed dependency file (uses specialized endpoints)

### SDK Coverage
- **14 total endpoints** (11 initial + 3 extended)
- **15 React Query hooks**
- **Full CRUD operations** for teams, members, invitations, roles

## Key Achievements

✅ 100% of migratable files now using SDK
✅ All user-facing team features migrated
✅ Public invitation flow fully functional
✅ Zero technical debt introduced
✅ Full type safety maintained throughout
✅ Comprehensive documentation updated
✅ Production-ready implementation

## Testing Notes

**Tested Flows:**
- Email invitation acceptance (token-based, public)
- Team member role updates (inline, authenticated)
- All invitation lifecycle operations (send, resend, accept, decline, cancel)

## Documentation

Updated TEAMS_MIGRATION_SUCCESS.md with:
- Final migration status (100% complete)
- All 3 SDK extensions documented
- Complete list of migrated files
- Migration patterns and best practices
- Rationale for non-migrated files

## Breaking Changes

None - all changes are internal migrations maintaining existing APIs.

## Next Steps

Teams migration is complete and production-ready. Recommended next phases:
- Phase 4: Prerequisites (onboarding)
- Phase 5: Applications/Jobs (high impact)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant