Aggancia funzioni di libreria e route push alla rosa reale
obiettivi.ts, palloni-core.ts, presenze-mese.ts e user-store.ts non dipendono più dalla lista statica di crapp-data.ts ma ricevono/leggono la rosa reale (percentuali obiettivo, rotazione turno palloni, riepilogo presenze mensile, identità del dispositivo). Le route API per le notifiche push (push-messaggio, promemoria-palloni, sollecita-presenze) leggono la squadra lato server con leggiGiocatoriSquadra(), filtrando attivo.
This commit is contained in:
1 parent
7e93229eee
commit
b6c0f40f66
8 files changed
+51
-25
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import { giocatori, type Giocatore } from "./crapp-data";
|
||||
import type { Giocatore } from "./crapp-data";
|
||||
import { useGiocatoriSquadra, type GiocatoreSquadra } from "./giocatori-squadra";
|
||||
import { useIo } from "./rosa";
|
||||
|
||||
const KEY = "crapp-user-v1";
|
||||
@@ -49,9 +50,10 @@ export function useGiocatoreId(): string | null {
|
||||
}
|
||||
|
||||
/** Anagrafica base dal localStorage: le statistiche restano a zero finché non passa da `useIo`. */
|
||||
export function useGiocatoreBase(): Giocatore | null {
|
||||
export function useGiocatoreBase(): GiocatoreSquadra | null {
|
||||
const id = useGiocatoreId();
|
||||
return id ? (giocatori.find((x) => x.id === id) ?? null) : null;
|
||||
const { righe } = useGiocatoriSquadra();
|
||||
return id ? (righe.find((x) => x.id === id) ?? null) : null;
|
||||
}
|
||||
|
||||
/** Giocatore corrente con statistiche calcolate da dati reali (presenze, MVP, badge, …). */
|
||||
|
||||
Reference in new issue
Block a user