Rompe il ciclo di import rosa ↔ user-store

useGiocatoreCorrente (alias di useIo) passa da user-store a rosa: user-store
non importa più rosa. Nessun cambio di comportamento.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-11-15 18:44:00 +01:00
1 parent cff78f941d
commit 4b5e7d91a1
3 files changed
+9 -8

No files matched your search

+8
View File
@@ -164,6 +164,14 @@ export function useIo(): Giocatore | null {
return rosa.find((g) => g.id === id) ?? null;
}
/**
* Giocatore corrente con statistiche calcolate da dati reali (presenze, MVP, badge, …).
* Sta qui e non in `user-store` per non chiudere il ciclo `rosa` ↔ `user-store`.
*/
export function useGiocatoreCorrente(): Giocatore | null {
return useIo();
}
/** Obiettivi collaborativi calcolati sui dati reali già in cache. */
export function useObiettivi() {
const rosa = useRosa();
-7
View File
@@ -1,7 +1,5 @@
import { useSyncExternalStore } from "react";
import type { Giocatore } from "./crapp-data";
import { isAllenatore, useGiocatoriSquadra, type GiocatoreSquadra } from "./giocatori-squadra";
import { useIo } from "./rosa";
const KEY = "crapp-user-v1";
const listeners = new Set<() => void>();
@@ -72,8 +70,3 @@ export function useGiocatoreInCampo(): GiocatoreSquadra | null {
const g = useGiocatoreBase();
return g && !isAllenatore(g) ? g : null;
}
/** Giocatore corrente con statistiche calcolate da dati reali (presenze, MVP, badge, …). */
export function useGiocatoreCorrente(): Giocatore | null {
return useIo();
}