diff --git a/src/components/crapp/CelebrazioneBadge.tsx b/src/components/crapp/CelebrazioneBadge.tsx index a7d2497..badd9be 100644 --- a/src/components/crapp/CelebrazioneBadge.tsx +++ b/src/components/crapp/CelebrazioneBadge.tsx @@ -3,7 +3,7 @@ import { X } from "lucide-react"; import { cn } from "@/lib/utils"; import { useVotiSocial } from "@/lib/badge-social"; import { useNotificheSmart } from "@/lib/notifiche-smart"; -import { useGiocatoreCorrente } from "@/lib/user-store"; +import { useGiocatoreCorrente } from "@/lib/rosa"; import { coriandoli, useMotoRidotto } from "@/lib/motion"; const toni: Record = { diff --git a/src/lib/rosa.ts b/src/lib/rosa.ts index 9fbb25b..821ae59 100644 --- a/src/lib/rosa.ts +++ b/src/lib/rosa.ts @@ -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(); diff --git a/src/lib/user-store.ts b/src/lib/user-store.ts index 10d6dd5..c3e3be0 100644 --- a/src/lib/user-store.ts +++ b/src/lib/user-store.ts @@ -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(); -}