Aggancia Squadra, Presenze, Pagelle, Scout e calendario alla rosa reale
convocatiEvento() e compleanniEventi() prendono ora la rosa come parametro invece di leggere la lista statica; csvScoutMatch() idem. Le schermate di gestione eventi, dettaglio allenamento/partita, calendario e scout live, più i widget di presenze/pagelle/voto MVP/voto social/sondaggio cacche/turno palloni, passano tutte la rosa letta da useRosa() o useGiocatoriSquadra(): un giocatore aggiunto o disattivato dalla dashboard admin ora si riflette ovunque.
This commit is contained in:
+7
-6
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { supabase } from "@/integrations/supabase/client";
|
||||
import { giocatori } from "./crapp-data";
|
||||
import type { Giocatore } from "./crapp-data";
|
||||
|
||||
export type EventoTipo = "partita" | "allenamento" | "evento" | "compleanno";
|
||||
|
||||
@@ -158,8 +158,9 @@ export function useEliminaEvento() {
|
||||
}
|
||||
|
||||
/** Compleanni della rosa, come eventi di calendario dell'anno indicato. */
|
||||
export function compleanniEventi(anno = new Date().getFullYear()): Evento[] {
|
||||
return giocatori
|
||||
export function compleanniEventi(rosa: Giocatore[], anno = new Date().getFullYear()): Evento[] {
|
||||
return rosa
|
||||
.filter((g) => g.nascita)
|
||||
.map((g) => {
|
||||
const md = g.nascita.slice(5);
|
||||
const eta = anno - Number(g.nascita.slice(0, 4));
|
||||
@@ -181,7 +182,7 @@ export function compleanniEventi(anno = new Date().getFullYear()): Evento[] {
|
||||
}
|
||||
|
||||
/** Rosa convocata per un evento: se non specificata vale tutta la rosa. */
|
||||
export function convocatiEvento(evento: Evento | null) {
|
||||
if (!evento || evento.convocati.length === 0) return giocatori;
|
||||
return giocatori.filter((g) => evento.convocati.includes(g.id));
|
||||
export function convocatiEvento(evento: Evento | null, rosa: Giocatore[]) {
|
||||
if (!evento || evento.convocati.length === 0) return rosa;
|
||||
return rosa.filter((g) => evento.convocati.includes(g.id));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { giocatori } from "./crapp-data";
|
||||
import type { Giocatore } from "./crapp-data";
|
||||
import { azioniMeta, totaliPerGiocatore, type ScoutMatch } from "./scout-store";
|
||||
|
||||
/** Riga CSV con separatore ";" (Excel IT), riusata anche dall'export tesseramento. */
|
||||
@@ -12,7 +12,7 @@ export function rigaCsv(campi: Array<string | number>) {
|
||||
}
|
||||
|
||||
/** Esporta la scoutizzazione di una partita in CSV (separatore ";" per Excel IT). */
|
||||
export function csvScoutMatch(match: ScoutMatch): string {
|
||||
export function csvScoutMatch(match: ScoutMatch, rosa: Giocatore[]): string {
|
||||
const righe: string[] = [];
|
||||
righe.push(
|
||||
rigaCsv([
|
||||
@@ -29,7 +29,7 @@ export function csvScoutMatch(match: ScoutMatch): string {
|
||||
righe.push("");
|
||||
righe.push(rigaCsv(["Numero", "Giocatore", "Ruolo", "Punti", "Ace", "Muri", "Errori"]));
|
||||
const totali = totaliPerGiocatore(match.azioni);
|
||||
for (const g of giocatori) {
|
||||
for (const g of rosa) {
|
||||
const t = totali.get(g.id);
|
||||
if (!t) continue;
|
||||
righe.push(rigaCsv([g.numero, g.nome, g.ruolo, t.punti, t.ace, t.muri, t.errori]));
|
||||
@@ -37,7 +37,7 @@ export function csvScoutMatch(match: ScoutMatch): string {
|
||||
righe.push("");
|
||||
righe.push(rigaCsv(["Set", "Giocatore", "Azione"]));
|
||||
for (const a of match.azioni) {
|
||||
const g = giocatori.find((x) => x.id === a.giocatoreId);
|
||||
const g = rosa.find((x) => x.id === a.giocatoreId);
|
||||
righe.push(rigaCsv([a.set, g?.nome ?? "—", azioniMeta[a.tipo].label]));
|
||||
}
|
||||
return righe.join("\n");
|
||||
|
||||
Reference in New Issue
Block a user