feat: implement onboarding flow with complex creation and email verification, and add Zustand for state management
This commit is contained in:
44
AGENTS.md
44
AGENTS.md
@@ -149,3 +149,47 @@ The app supports users with multiple complexes. Each user has a role per complex
|
||||
### Profile Role
|
||||
|
||||
The profile page shows the user's role for the **selected complex**, not the global user role. This is fetched from `ComplexUser` table using the cookie value.
|
||||
|
||||
## Frontend API Client
|
||||
|
||||
The API client is split into modular files for better maintainability and testability.
|
||||
|
||||
### Structure
|
||||
|
||||
```
|
||||
lib/
|
||||
├── api-client.ts # Main barrel file (~70 lines)
|
||||
└── api/
|
||||
├── base.ts # ApiClientError, configureApiClient, apiBaseUrl
|
||||
├── http.ts # Axios instance with interceptors
|
||||
├── index.ts # Re-exports all resources
|
||||
└── resources/
|
||||
├── complexes.ts # Complex endpoints
|
||||
├── courts.ts # Court endpoints
|
||||
├── bookings.ts # Public & admin booking endpoints
|
||||
├── user.ts # User profile endpoint
|
||||
├── sports.ts # Sport endpoints
|
||||
├── onboarding.ts # Onboarding endpoints
|
||||
└── plans.ts # Plan endpoints
|
||||
```
|
||||
|
||||
### Using the API Client
|
||||
|
||||
```typescript
|
||||
import { apiClient, authClient, ApiClientError, configureApiClient } from '@/lib/api-client';
|
||||
|
||||
// Via apiClient (barrel)
|
||||
await apiClient.complexes.listMine();
|
||||
await apiClient.publicBookings.getAvailability('my-club', { date: '2026-04-20' });
|
||||
|
||||
// Direct imports (for better tree-shaking)
|
||||
import { complexes, getAvailability } from '@/lib/api';
|
||||
await complexes.listMine();
|
||||
await getAvailability('my-club', { date: '2026-04-20' });
|
||||
```
|
||||
|
||||
### Adding a New Resource
|
||||
|
||||
1. Create `lib/api/resources/[resource].ts`
|
||||
2. Export functions using `http` from `../http`
|
||||
3. Add exports in `lib/api/index.ts`
|
||||
|
||||
Reference in New Issue
Block a user