fix: update documentation and configuration files

This commit is contained in:
2026-03-29 19:26:50 -07:00
parent 00aa8cf044
commit 26d9c7e79e
50 changed files with 6264 additions and 2627 deletions
+43
View File
@@ -0,0 +1,43 @@
# Tournament Status Fix
## Problem
Tournaments with past `eventDate` were incorrectly showing as "planned" because the `status` field was static and only updated when explicitly changed.
## Solution
Implemented dynamic status calculation based on event date that automatically updates when tournaments are fetched.
## Changes Made
### 1. Created `src/lib/tournamentUtils.ts`
- Added `getTournamentStatus(eventDate: Date | null): string` function
- Returns "completed" if eventDate is in the past
- Returns "planned" if eventDate is in the future or null
- Added helper functions `isTournamentPast()` and `isTournamentFuture()`
### 2. Updated `src/app/api/tournaments/route.ts`
- Modified GET endpoint to automatically update tournament statuses
- Fetches all tournaments with participants and teams
- Calculates status using `getTournamentStatus()` for each tournament
- Updates database if calculated status differs from stored status
- Returns tournaments with updated status
### 3. Updated `src/app/admin/tournaments/page.tsx`
- Added import for `getTournamentStatus` utility
- Calculates dynamic status for each tournament before rendering
- Updates database if status needs to change
- Displays calculated status in UI
### 4. Updated `src/app/admin/tournaments/[id]/page.tsx`
- Added import for `getTournamentStatus` utility
- Calculates and updates tournament status before rendering detail page
- Ensures consistent status display across all tournament views
## Status Logic
- **Past eventDate** → "completed" (gray badge: bg-gray-100 text-gray-800)
- **Future eventDate or null** → "planned" (yellow badge: bg-yellow-100 text-yellow-800)
## Behavior
- Status is automatically calculated and updated whenever tournaments are fetched
- No manual intervention required
- Existing tournaments with past dates are automatically marked as "completed"
- Future tournaments or tournaments without dates remain "planned"