feat: add Settings page with hijri seasons CRUD
- Server: seasons CRUD routes + generic NocoDB helpers - Client: Settings page at /settings with inline add/edit/delete - Seasons stored in NocoDB Seasons table - Vite proxy: /api/seasons routed to Express server - Nav links added (desktop + mobile) - Locale keys for EN + AR - Seasons loaded non-blocking on app mount Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
37
src/services/seasonsService.ts
Normal file
37
src/services/seasonsService.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { Season } from '../types';
|
||||
|
||||
export async function fetchSeasons(): Promise<Season[]> {
|
||||
try {
|
||||
const res = await fetch('/api/seasons');
|
||||
if (!res.ok) return [];
|
||||
return res.json();
|
||||
} catch {
|
||||
console.warn('Failed to load seasons, using empty list');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function createSeason(season: Omit<Season, 'Id'>): Promise<Season> {
|
||||
const res = await fetch('/api/seasons', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(season),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to create season');
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function updateSeason(id: number, season: Partial<Season>): Promise<Season> {
|
||||
const res = await fetch(`/api/seasons/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(season),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to update season');
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function deleteSeason(id: number): Promise<void> {
|
||||
const res = await fetch(`/api/seasons/${id}`, { method: 'DELETE' });
|
||||
if (!res.ok) throw new Error('Failed to delete season');
|
||||
}
|
||||
Reference in New Issue
Block a user