Sistema tutti gli errori di lint (prettier) rimasti su main
npx eslint --fix su test/unit/obiettivi.test.ts, test/integration/obiettivi.test.ts, BarraSottosezioni.tsx, EventoCard.tsx e calendario.tsx — solo formattazione, nessuna modifica di comportamento. Verificato con la suite unit (32/32 verde). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -90,9 +90,7 @@ export function BarraSottosezioni({
|
|||||||
aria-label="Sottosezioni"
|
aria-label="Sottosezioni"
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex flex-nowrap",
|
"flex flex-nowrap",
|
||||||
riempiLarghezza
|
riempiLarghezza ? "w-full" : "w-max min-w-full",
|
||||||
? "w-full"
|
|
||||||
: "w-max min-w-full",
|
|
||||||
sottolineatura ? "gap-1 px-2 py-1.5" : "snap-x snap-mandatory gap-1.5 px-5",
|
sottolineatura ? "gap-1 px-2 py-1.5" : "snap-x snap-mandatory gap-1.5 px-5",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -88,8 +88,7 @@ export function EventoCard({
|
|||||||
const passato = evento.data < dataOggi();
|
const passato = evento.data < dataOggi();
|
||||||
const cliccabile = Boolean(linkTo);
|
const cliccabile = Boolean(linkTo);
|
||||||
/** Solo gli eventi extra-campo non hanno scheda dedicata: le note restano sulla card. */
|
/** Solo gli eventi extra-campo non hanno scheda dedicata: le note restano sulla card. */
|
||||||
const noteCard =
|
const noteCard = evento.tipo === "evento" ? evento.note.trim() : "";
|
||||||
evento.tipo === "evento" ? evento.note.trim() : "";
|
|
||||||
const stati =
|
const stati =
|
||||||
evento.tipo === "evento"
|
evento.tipo === "evento"
|
||||||
? // Se resta un vecchio "infortunato", mostra il bottone solo per poterlo togliere.
|
? // Se resta un vecchio "infortunato", mostra il bottone solo per poterlo togliere.
|
||||||
@@ -193,10 +192,7 @@ export function EventoCard({
|
|||||||
|
|
||||||
{io ? (
|
{io ? (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn("pointer-events-auto flex w-full gap-1", metaStato ? "mt-2.5" : "mt-3")}
|
||||||
"pointer-events-auto flex w-full gap-1",
|
|
||||||
metaStato ? "mt-2.5" : "mt-3",
|
|
||||||
)}
|
|
||||||
role="group"
|
role="group"
|
||||||
aria-label="La tua presenza"
|
aria-label="La tua presenza"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -96,7 +96,10 @@ if (!locale) {
|
|||||||
giocatore_id: g.id,
|
giocatore_id: g.id,
|
||||||
stato: presenti.includes(g.id) ? "presente" : "assente",
|
stato: presenti.includes(g.id) ? "presente" : "assente",
|
||||||
}));
|
}));
|
||||||
const inseritePresenze = await rest("risposte_presenze", { method: "POST", body: JSON.stringify(righe) });
|
const inseritePresenze = await rest("risposte_presenze", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(righe),
|
||||||
|
});
|
||||||
if (!inseritePresenze.ok) {
|
if (!inseritePresenze.ok) {
|
||||||
throw new Error(`inserimento presenze fallito: ${await inseritePresenze.text()}`);
|
throw new Error(`inserimento presenze fallito: ${await inseritePresenze.text()}`);
|
||||||
}
|
}
|
||||||
@@ -195,7 +198,11 @@ if (!locale) {
|
|||||||
|
|
||||||
// Tutta la rosa presente all'allenamento, nessuno alla partita: 50% aggregato sui due.
|
// Tutta la rosa presente all'allenamento, nessuno alla partita: 50% aggregato sui due.
|
||||||
const risposte = [
|
const risposte = [
|
||||||
...giocatori.map((g) => ({ evento_id: allenamentoId, giocatore_id: g.id, stato: "presente" })),
|
...giocatori.map((g) => ({
|
||||||
|
evento_id: allenamentoId,
|
||||||
|
giocatore_id: g.id,
|
||||||
|
stato: "presente",
|
||||||
|
})),
|
||||||
...giocatori.map((g) => ({ evento_id: partitaId, giocatore_id: g.id, stato: "assente" })),
|
...giocatori.map((g) => ({ evento_id: partitaId, giocatore_id: g.id, stato: "assente" })),
|
||||||
];
|
];
|
||||||
const scritte = await rest("risposte_presenze", {
|
const scritte = await rest("risposte_presenze", {
|
||||||
@@ -379,9 +386,7 @@ if (!locale) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await prova(
|
await prova("o7 somma presenze calcolate da eventi/risposte reali del database", async () => {
|
||||||
"o7 somma presenze calcolate da eventi/risposte reali del database",
|
|
||||||
async () => {
|
|
||||||
// o7 non calcola nulla da `ctx`: somma `g.presenze`, un campo già calcolato a monte da
|
// o7 non calcola nulla da `ctx`: somma `g.presenze`, un campo già calcolato a monte da
|
||||||
// `contaPresenzeGiocatore()` (che in produzione alimenta `useRosa()`). Qui si esercita
|
// `contaPresenzeGiocatore()` (che in produzione alimenta `useRosa()`). Qui si esercita
|
||||||
// la stessa funzione pura sui dati appena scritti, per verificare l'intera catena
|
// la stessa funzione pura sui dati appena scritti, per verificare l'intera catena
|
||||||
@@ -412,7 +417,10 @@ if (!locale) {
|
|||||||
{ evento_id: allenamentoId, giocatore_id: g3!.id, stato: "assente" },
|
{ evento_id: allenamentoId, giocatore_id: g3!.id, stato: "assente" },
|
||||||
{ evento_id: partitaId, giocatore_id: g3!.id, stato: "assente" },
|
{ evento_id: partitaId, giocatore_id: g3!.id, stato: "assente" },
|
||||||
];
|
];
|
||||||
const inserite = await rest("risposte_presenze", { method: "POST", body: JSON.stringify(righe) });
|
const inserite = await rest("risposte_presenze", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(righe),
|
||||||
|
});
|
||||||
if (!inserite.ok) throw new Error(`inserimento presenze fallito: ${await inserite.text()}`);
|
if (!inserite.ok) throw new Error(`inserimento presenze fallito: ${await inserite.text()}`);
|
||||||
|
|
||||||
const eventiReali = (await leggiEventi()).filter(
|
const eventiReali = (await leggiEventi()).filter(
|
||||||
@@ -428,16 +436,18 @@ if (!locale) {
|
|||||||
presenze: contaPresenzeGiocatore(g.id, eventiReali, presenzeReali, OGGI_STR),
|
presenze: contaPresenzeGiocatore(g.id, eventiReali, presenzeReali, OGGI_STR),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const o7 = obiettiviSquadra(rosaConPresenzeReali, { eventi: [], presenze: {}, pagelle: [] })
|
const o7 = obiettiviSquadra(rosaConPresenzeReali, {
|
||||||
.find((o) => o.id === "o7")!;
|
eventi: [],
|
||||||
|
presenze: {},
|
||||||
|
pagelle: [],
|
||||||
|
}).find((o) => o.id === "o7")!;
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
o7.valore,
|
o7.valore,
|
||||||
4,
|
4,
|
||||||
"g1 (2) + g2 (2, il ritardo conta) + g3 (0) = 4, calcolate dal database",
|
"g1 (2) + g2 (2, il ritardo conta) + g3 (0) = 4, calcolate dal database",
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
await prova("o12/o13 media e conteggio pagelle vere lette da pagelle_voti", async () => {
|
await prova("o12/o13 media e conteggio pagelle vere lette da pagelle_voti", async () => {
|
||||||
const matchId = `${PREFISSO}-o12-m1`;
|
const matchId = `${PREFISSO}-o12-m1`;
|
||||||
@@ -522,20 +532,26 @@ if (!locale) {
|
|||||||
});
|
});
|
||||||
if (!inserite.ok) throw new Error(`inserimento presenze fallito: ${await inserite.text()}`);
|
if (!inserite.ok) throw new Error(`inserimento presenze fallito: ${await inserite.text()}`);
|
||||||
|
|
||||||
const eventiReali = (await leggiEventi()).filter((e) =>
|
const eventiReali = (await leggiEventi()).filter((e) => eventi.some(([id]) => id === e.id));
|
||||||
eventi.some(([id]) => id === e.id),
|
|
||||||
);
|
|
||||||
const presenzeReali: MappaPresenze = {};
|
const presenzeReali: MappaPresenze = {};
|
||||||
for (const [id] of eventi) Object.assign(presenzeReali, await leggiPresenze(id));
|
for (const [id] of eventi) Object.assign(presenzeReali, await leggiPresenze(id));
|
||||||
|
|
||||||
const rosaConSerieReali = [g1!, g2!, g3!].map((g) => ({
|
const rosaConSerieReali = [g1!, g2!, g3!].map((g) => ({
|
||||||
...g,
|
...g,
|
||||||
serieAllenamenti: serieConsecutiva(g.id, eventiReali, presenzeReali, "allenamento", OGGI_STR),
|
serieAllenamenti: serieConsecutiva(
|
||||||
|
g.id,
|
||||||
|
eventiReali,
|
||||||
|
presenzeReali,
|
||||||
|
"allenamento",
|
||||||
|
OGGI_STR,
|
||||||
|
),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const o11 = obiettiviSquadra(rosaConSerieReali, { eventi: [], presenze: {}, pagelle: [] }).find(
|
const o11 = obiettiviSquadra(rosaConSerieReali, {
|
||||||
(o) => o.id === "o11",
|
eventi: [],
|
||||||
)!;
|
presenze: {},
|
||||||
|
pagelle: [],
|
||||||
|
}).find((o) => o.id === "o11")!;
|
||||||
assert.equal(
|
assert.equal(
|
||||||
o11.valore,
|
o11.valore,
|
||||||
1,
|
1,
|
||||||
|
|||||||
@@ -126,7 +126,10 @@ assert.equal(trova(obiettiviSquadra(giocatori, soloCompleanni, OGGI_AGOSTO), "o2
|
|||||||
assert.equal(o1Agosto.scadenza, "2026-08-31", "scadenza = ultimo giorno del mese");
|
assert.equal(o1Agosto.scadenza, "2026-08-31", "scadenza = ultimo giorno del mese");
|
||||||
|
|
||||||
const o1Settembre = trova(obiettiviSquadra(giocatori, contestoVuoto, OGGI_SETTEMBRE), "o1");
|
const o1Settembre = trova(obiettiviSquadra(giocatori, contestoVuoto, OGGI_SETTEMBRE), "o1");
|
||||||
assert.ok(o1Settembre.titolo.includes("settembre"), "titolo o1 riflette il mese iniettato (settembre)");
|
assert.ok(
|
||||||
|
o1Settembre.titolo.includes("settembre"),
|
||||||
|
"titolo o1 riflette il mese iniettato (settembre)",
|
||||||
|
);
|
||||||
assert.equal(o1Settembre.scadenza, "2026-09-30", "scadenza = ultimo giorno di settembre (30 gg)");
|
assert.equal(o1Settembre.scadenza, "2026-09-30", "scadenza = ultimo giorno di settembre (30 gg)");
|
||||||
|
|
||||||
// La scadenza di o2 ("Tutti rispondono alle convocazioni") era una data fissa
|
// La scadenza di o2 ("Tutti rispondono alle convocazioni") era una data fissa
|
||||||
@@ -197,10 +200,7 @@ assert.equal(trova(obiettiviSquadra(giocatori, soloCompleanni, OGGI_AGOSTO), "o2
|
|||||||
);
|
);
|
||||||
|
|
||||||
const dueEventiRisposte: ContestoObiettivi = {
|
const dueEventiRisposte: ContestoObiettivi = {
|
||||||
eventi: [
|
eventi: [evento("dr1", "2026-08-03", "allenamento"), evento("dr2", "2026-08-17", "partita")],
|
||||||
evento("dr1", "2026-08-03", "allenamento"),
|
|
||||||
evento("dr2", "2026-08-17", "partita"),
|
|
||||||
],
|
|
||||||
presenze: {
|
presenze: {
|
||||||
dr1: Object.fromEntries(giocatori.map((g) => [g.id, "presente" as const])),
|
dr1: Object.fromEntries(giocatori.map((g) => [g.id, "presente" as const])),
|
||||||
dr2: {},
|
dr2: {},
|
||||||
|
|||||||
Reference in New Issue
Block a user