website refactor
This commit is contained in:
@@ -250,14 +250,23 @@ Minimal guardrails that pay off:
|
||||
|
||||
- The “mess” is client-side writes bypassing this.
|
||||
|
||||
### 5.3 React Query usage: is it even used?
|
||||
### 5.4 Command Models: Are they useless?
|
||||
|
||||
Yes.
|
||||
No. Command Models (e.g., [`LoginCommandModel`](apps/website/lib/command-models/auth/LoginCommandModel.ts)) remain valuable as **optional UX helpers**.
|
||||
|
||||
- React Query exists in dependencies: [`apps/website/package.json`](apps/website/package.json:16)
|
||||
- There are dozens of hooks using it (search results in workspace).
|
||||
- **Purpose**: They manage transient form state and perform client-side UX validation.
|
||||
- **Relationship to Server Actions**: They prepare the DTO that is passed *to* the Server Action.
|
||||
- **Boundary**: They belong to the client-side "intent collection" phase. Once the Server Action is called, the Command Model's job is done.
|
||||
- **Redundancy**: They are **not redundant** with ViewModels. ViewModels are for the **read path** (API -> UI), while Command Models are for the **write path** (UI -> API).
|
||||
|
||||
The problem is not React Query for reads. The problem is React Query being used as the write mechanism.
|
||||
### 5.5 Identified places for Command Model usage
|
||||
|
||||
The following components currently use complex React state for forms and should be refactored to use Command Models:
|
||||
|
||||
1. **[`CreateLeagueWizard.tsx`](apps/website/app/leagues/create/CreateLeagueWizard.tsx)**: Needs a `CreateLeagueCommandModel` to manage multi-step wizard state and validation.
|
||||
2. **[`LeagueAdminSchedulePageClient.tsx`](apps/website/app/leagues/[id]/schedule/admin/LeagueAdminSchedulePageClient.tsx)**: Should use a `RaceScheduleCommandModel` for the track/car/date fields.
|
||||
3. **[`ProtestDetailPageClient.tsx`](apps/website/app/leagues/[id]/stewarding/protests/[protestId]/ProtestDetailPageClient.tsx)**: Should fully leverage the existing [`ProtestDecisionCommandModel`](apps/website/lib/command-models/protests/ProtestDecisionCommandModel.ts).
|
||||
4. **[`SponsorSignupPage`](apps/website/app/sponsor/signup/page.tsx)**: Needs a `SponsorSignupCommandModel` to clean up the `formData` and `errors` state.
|
||||
|
||||
---
|
||||
|
||||
@@ -296,11 +305,15 @@ Concrete example of why you feel “ViewModels are pushed away by ViewData”:
|
||||
The following cleanups have been implemented:
|
||||
|
||||
1. **Deterministic Formatting**: Removed `toLocaleString()` and `toLocaleDateString()` from all templates. Introduced `NumberDisplay` and `DateDisplay` display objects for deterministic formatting.
|
||||
2. **Server Action Migration**: Migrated `LeagueAdminSchedulePageClient.tsx` from React Query `useMutation` to Next.js Server Actions.
|
||||
2. **Server Action Migration**: Migrated the schedule administration logic in `LeagueAdminSchedulePageClient.tsx` from React Query `useMutation` to Next.js Server Actions.
|
||||
3. **Onboarding Consolidation**: Updated onboarding hooks to use server actions instead of direct service calls.
|
||||
4. **ViewModel Builders**: Introduced `LeagueSummaryViewModelBuilder` to eliminate ad-hoc ViewData -> ViewModel mapping in `LeaguesPageClient.tsx`.
|
||||
5. **React Query Deprecation**: Deprecated `usePageMutation` in `usePageData.ts`.
|
||||
6. **Guardrails**: Added `gridpilot-rules/no-use-mutation-in-client` ESLint rule to prevent future React Query write usage.
|
||||
7. **Command Models**:
|
||||
- Created [`RaceScheduleCommandModel`](apps/website/lib/command-models/leagues/RaceScheduleCommandModel.ts) and integrated it into [`LeagueAdminSchedulePageClient.tsx`](apps/website/app/leagues/[id]/schedule/admin/LeagueAdminSchedulePageClient.tsx).
|
||||
- Created [`SponsorSignupCommandModel`](apps/website/lib/command-models/sponsors/SponsorSignupCommandModel.ts) and integrated it into [`SponsorSignupPage`](apps/website/app/sponsor/signup/page.tsx).
|
||||
- Ensured [`LeagueWizardCommandModel`](apps/website/lib/command-models/leagues/LeagueWizardCommandModel.ts) is ready for future refactoring of the complex wizard.
|
||||
|
||||
## 8) Next Steps for the Team
|
||||
|
||||
|
||||
Reference in New Issue
Block a user