diff --git a/src/components/crapp/EventoCard.tsx b/src/components/crapp/EventoCard.tsx index f583865..6f81405 100644 --- a/src/components/crapp/EventoCard.tsx +++ b/src/components/crapp/EventoCard.tsx @@ -1,11 +1,12 @@ import { MapPin, Clock, Users, Cake, ArrowRight } from "lucide-react"; import { Link } from "@tanstack/react-router"; import { cn } from "@/lib/utils"; -import { formatData, giocatori, statoMeta, type Stato } from "@/lib/crapp-data"; +import { formatData, statoMeta, type Stato } from "@/lib/crapp-data"; import type { Evento } from "@/lib/eventi"; import { Barra } from "@/components/motion/Barra"; import { usePresenzeEvento, useSalvaPresenza } from "@/lib/presenze"; import { useGiocatoreCorrente } from "@/lib/user-store"; +import { useRosaBase } from "@/lib/rosa-base"; const tipoMeta = { partita: { label: "Partita", className: "bg-accent text-accent-foreground" }, @@ -36,6 +37,7 @@ export function EventoCard({ const { risposte } = usePresenzeEvento(evento.id); const salva = useSalvaPresenza(); const io = useGiocatoreCorrente(); + const giocatori = useRosaBase(); const stato = io ? risposte[io.id] : undefined; const presentiVeri = giocatori.filter( (g) => risposte[g.id] === "presente" || risposte[g.id] === "ritardo", @@ -118,33 +120,35 @@ export function EventoCard({ {io ? ( -
- {stati.map((s) => { - const meta = statoMeta[s]; - const attivo = stato === s; - return ( - - ); - })} -
+
+ {stati.map((s) => { + const meta = statoMeta[s]; + const attivo = stato === s; + return ( + + ); + })} +
) : null} ); -} \ No newline at end of file +} diff --git a/src/components/crapp/Pagelle.tsx b/src/components/crapp/Pagelle.tsx index 5ebfe43..b75fb11 100644 --- a/src/components/crapp/Pagelle.tsx +++ b/src/components/crapp/Pagelle.tsx @@ -3,7 +3,8 @@ import { ClipboardCheck, Lock } from "lucide-react"; import { toast } from "sonner"; import { cn } from "@/lib/utils"; import { Avatar } from "@/components/crapp/Avatar"; -import { giocatori } from "@/lib/crapp-data"; +import type { Giocatore } from "@/lib/crapp-data"; +import { useRosaBase } from "@/lib/rosa-base"; import { useGiocatoreCorrente } from "@/lib/user-store"; import { mieiVoti, pagellePartita, usePagelle, useVotaPagella } from "@/lib/pagelle"; @@ -12,21 +13,23 @@ const voti = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; /** Pagelle di fine partita: voto anonimo 1-10 a ciascun compagno. */ export function Pagelle({ matchId, - convocati = giocatori, + convocati, chiuse = false, }: { matchId: string; - convocati?: typeof giocatori; + convocati?: Giocatore[]; chiuse?: boolean; }) { + const rosaBase = useRosaBase(); const io = useGiocatoreCorrente(); const { voti: tutti, isPending } = usePagelle(); const vota = useVotaPagella(); const [apertoPer, setApertoPer] = useState(null); + const lista = convocati ?? rosaBase; const medie = pagellePartita(tutti, matchId); const miei = io ? mieiVoti(tutti, matchId, io.id) : {}; - const daVotare = convocati.filter((g) => g.id !== io?.id); + const daVotare = lista.filter((g) => g.id !== io?.id); const fatti = daVotare.filter((g) => miei[g.id] !== undefined).length; async function invia(votatoId: string, voto: number) { @@ -58,7 +61,7 @@ export function Pagelle({

Carico le pagelle…

) : (
- {convocati.map((g) => { + {lista.map((g) => { const media = medie[g.id]; const mio = miei[g.id]; const sonoIo = g.id === io?.id; @@ -104,7 +107,9 @@ export function Pagelle({ onClick={() => invia(g.id, v)} className={cn( "rounded-lg py-1.5 text-[11px] font-bold tabular-nums transition-transform active:scale-90", - mio === v ? "bg-accent text-accent-foreground" : "bg-card text-foreground", + mio === v + ? "bg-accent text-accent-foreground" + : "bg-card text-foreground", )} > {v} diff --git a/src/components/crapp/RosaPresenze.tsx b/src/components/crapp/RosaPresenze.tsx index 8836039..cfacc21 100644 --- a/src/components/crapp/RosaPresenze.tsx +++ b/src/components/crapp/RosaPresenze.tsx @@ -4,7 +4,8 @@ import { toast } from "sonner"; import { cn } from "@/lib/utils"; import { Avatar } from "@/components/crapp/Avatar"; import { Barra } from "@/components/motion/Barra"; -import { giocatori, isAdmin, statoMeta, type Stato } from "@/lib/crapp-data"; +import { isAdmin, statoMeta, type Giocatore, type Stato } from "@/lib/crapp-data"; +import { useRosaBase } from "@/lib/rosa-base"; import { usePresenzeEvento, useSalvaPresenza } from "@/lib/presenze"; import { useGiocatoreCorrente } from "@/lib/user-store"; @@ -14,12 +15,14 @@ export function RosaPresenze({ eventoId }: { eventoId: string }) { const { risposte, isPending } = usePresenzeEvento(eventoId); const salva = useSalvaPresenza(); const io = useGiocatoreCorrente(); + const giocatori = useRosaBase(); const [sollecito, setSollecito] = useState(false); const mancanti = giocatori.filter((g) => !risposte[g.id]); const risposteN = giocatori.length - mancanti.length; const perc = Math.round((risposteN / giocatori.length) * 100); - const daSollecitare = mancanti.length + giocatori.filter((g) => risposte[g.id] === "forse").length; + const daSollecitare = + mancanti.length + giocatori.filter((g) => risposte[g.id] === "forse").length; async function sollecita() { setSollecito(true); @@ -105,7 +108,7 @@ export function RosaPresenze({ eventoId }: { eventoId: string }) {
) : null} - {io && isAdmin(io.id) ? ( + {io && isAdmin(io) ? (