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 -3
View File
@@ -1,5 +1,6 @@
import { useSyncExternalStore } from "react";
import { giocatori, type Giocatore } from "./crapp-data";
import type { Giocatore } from "./crapp-data";
import { useRosaBase } from "./rosa-base";
import { conInfortuni, useInfortuniERitardi } from "./infortuni";
const KEY = "crapp-user-v1";
@@ -36,7 +37,7 @@ export function resetGiocatore() {
write(null);
}
/** Solo lettura locale: nessuna dipendenza da React Query (usabile fuori dal provider). */
/** Richiede un ancestor QueryClientProvider (la rosa base arriva dal CMS Strapi). */
export function useGiocatoreBase(): Giocatore | null {
const id = useSyncExternalStore(
(cb) => {
@@ -46,7 +47,8 @@ export function useGiocatoreBase(): Giocatore | null {
() => read(),
() => null,
);
return id ? (giocatori.find((x) => x.id === id) ?? null) : null;
const rosa = useRosaBase();
return id ? (rosa.find((x) => x.id === id) ?? null) : null;
}
export function useGiocatoreCorrente(): Giocatore | null {