Sposto rosa, classifica e storico partite dagli array hardcoded al CMS Strapi

Nuovi moduli src/lib/strapi-client.ts + rosa-base.ts/classifica-csi.ts/
storico-match.ts (hook TanStack Query, cache lunga, nessun polling). L'id
stabile gN diventa il campo `codice` su Strapi, per non rompere le FK verso
pagelle/cacche/mvp/palloni/presenze/azioni scout già chiavate su quella
stringa. isAdmin ora prende il Giocatore invece di un id, così non dipende
più dal roster. Rifattorizzati di conseguenza tutti i punti che importavano
`giocatori`/`classifica`/`storicoMatch` come array sincroni (componenti,
hook, due route server) per usare gli hook o un parametro esplicito.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-28 15:39:40 +02:00
co-authored by Claude Sonnet 5
parent 3f61b32219
commit 953908388d
36 changed files with 678 additions and 364 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
import { useMemo } from "react";
import { useEventi } from "./eventi";
import { useRispostePresenze } from "./presenze";
import { giocatori } from "./crapp-data";
import { useRosaBase } from "./rosa-base";
/**
* Percentuale di presenze dell'ultimo mese (30 giorni), utile per le convocazioni.
@@ -46,6 +46,7 @@ export function usePresenzeUltimoMeseTutti(): Record<
> {
const { eventi } = useEventi();
const { presenze } = useRispostePresenze();
const giocatori = useRosaBase();
return useMemo(() => {
const oggi = new Date();
@@ -60,8 +61,7 @@ export function usePresenzeUltimoMeseTutti(): Record<
const out: Record<string, { presenti: number; totali: number; percentuale: number }> = {};
for (const e of rilevanti) {
const ids =
e.convocati.length > 0 ? e.convocati : giocatori.map((g) => g.id);
const ids = e.convocati.length > 0 ? e.convocati : giocatori.map((g) => g.id);
for (const id of ids) {
const rec = (out[id] ??= { presenti: 0, totali: 0, percentuale: 0 });
rec.totali += 1;
@@ -73,5 +73,5 @@ export function usePresenzeUltimoMeseTutti(): Record<
rec.percentuale = rec.totali ? Math.round((rec.presenti / rec.totali) * 100) : 0;
}
return out;
}, [eventi, presenze]);
}
}, [eventi, presenze, giocatori]);
}