Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcff950006 | ||
|
|
99ca3b6495 | ||
|
|
457a0fe23d | ||
|
|
d8fc6ef04f | ||
|
|
e99d853987 | ||
|
|
efca4243b6 | ||
|
|
abd6fafc0c | ||
|
|
d52ceeb0f9 | ||
|
|
a9f146d77e |
@@ -1,38 +0,0 @@
|
|||||||
# Obiettivi di squadra: sezione in Squadra + widget in home
|
|
||||||
|
|
||||||
## Stato attuale
|
|
||||||
|
|
||||||
Al momento c'è un solo "obiettivo di squadra" ed è hardcoded nella home (`src/routes/index.tsx`, riga 136): **"90% di presenze ad agosto"** con una barra finta all'82%. Non esiste uno schema dati né una sezione dedicata, e non è collegato a calendario, presenze o statistiche. Le voci "obiettivi" nelle descrizioni di Squadra e Profilo si riferiscono ai badge individuali, non a obiettivi di squadra.
|
|
||||||
|
|
||||||
## Cosa faccio
|
|
||||||
|
|
||||||
1. **Modello dati locale** in `src/lib/crapp-data.ts`
|
|
||||||
|
|
||||||
- Nuovo tipo `ObiettivoSquadra`: id, titolo, descrizione, target, valore attuale, unità, scadenza (opzionale), icona.
|
|
||||||
- Array `obiettiviSquadra` con gli obiettivi demo della stagione.
|
|
||||||
|
|
||||||
2. **Sezione "Obiettivi di squadra" dentro la scheda Squadra** (`src/routes/squadra.tsx`)
|
|
||||||
|
|
||||||
- Nuova sezione con la lista completa degli obiettivi: barra di progresso, percentuale, stato (in corso / completato).
|
|
||||||
- Ordinati con gli obiettivi in corso in cima e i completati in fondo.
|
|
||||||
- Nessuna nuova rotta e nessuna modifica al bottom nav.
|
|
||||||
|
|
||||||
3. **Widget home dinamico** (`src/routes/index.tsx`)
|
|
||||||
|
|
||||||
- Sostituisce l'obiettivo hardcoded: mostra sempre il primo obiettivo in corso preso dalla lista.
|
|
||||||
- Progresso calcolato dai dati reali dove possibile (es. presenze derivate dagli eventi).
|
|
||||||
|
|
||||||
4. **Obiettivi demo iniziali**
|
|
||||||
|
|
||||||
- 90% di presenze ad agosto (collegato agli eventi di agosto).
|
|
||||||
- 70% di risposte entro 24h nel prossimo mese.
|
|
||||||
- Prima vittoria del campionato (collegato allo storico match).
|
|
||||||
- 5 vittorie in campionato (collegato allo storico match).
|
|
||||||
- 10 vittorie in campionato (collegato allo storico match).
|
|
||||||
- 1 evento di squadra al mese (pizzata, ecc.).
|
|
||||||
|
|
||||||
## Cosa non cambia
|
|
||||||
|
|
||||||
- Resta un prototipo offline: i dati restano in `src/lib/crapp-data.ts`.
|
|
||||||
- I badge individuali restano come sono in `src/lib/badges.ts` e nella rosa di `src/routes/squadra.tsx`.
|
|
||||||
- Bottom nav e rotte invariate.
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
# Rendere CrAPP operativa: migrazione dal prototipo al Cloud
|
|
||||||
|
|
||||||
## Stato attuale
|
|
||||||
|
|
||||||
L'app è un prototipo UI con alcune funzioni già collegate a Lovable Cloud:
|
|
||||||
|
|
||||||
- Già sul Cloud: voti MVP (`mvp_voti`), iscrizioni push (`push_subscriptions`), sessioni scout (`scout_sessioni`), turni palloni (`turni_palloni`).
|
|
||||||
- Ancora in locale come dati demo: rosa giocatori, calendario eventi, storico partite, classifica CSI, statistiche individuali, presenze/assenze, badge.
|
|
||||||
|
|
||||||
## Cosa serve per renderla operativa
|
|
||||||
|
|
||||||
1. **Rosa e profili giocatori sul database**
|
|
||||||
- Creare tabella `profiles` (o `giocatori`) con nome, numero maglia, ruolo, data di nascita, foto profilo.
|
|
||||||
- Collegare ogni riga all'utente autenticato corrispondente.
|
|
||||||
- Rimuovere la rosa statica da `src/lib/crapp-data.ts` e caricarla dal backend.
|
|
||||||
|
|
||||||
2. **Autenticazione reale**
|
|
||||||
- Sostituire la semplice selezione "Chi sei?" in `localStorage` con login email/password o OAuth (Google).
|
|
||||||
- Ogni giocatore accede con le proprie credenziali e vede solo i propri dati modificabili.
|
|
||||||
- Necessaria per garantire che uno scout o un voto MVP provenga davvero da quel giocatore.
|
|
||||||
|
|
||||||
3. **Calendario eventi persistente**
|
|
||||||
- Tabella `eventi` con tipo, titolo, data, ora, luogo, avversario, casa/fuori.
|
|
||||||
- Tabella `presenze` (evento_id, giocatore_id, stato, aggiornato_il).
|
|
||||||
- I compleanni possono restare derivati dalla data di nascita dei giocatori.
|
|
||||||
|
|
||||||
4. **Statistiche e badge dinamici**
|
|
||||||
- Tabella `statistiche` o `azioni_scout` (evento_id, giocatore_id, tipo azione, valore, creato_il).
|
|
||||||
- I badge vengono calcolati in tempo reale dalle statistiche accumulate, senza valori fissi in `crapp-data.ts`.
|
|
||||||
|
|
||||||
5. **Scout live collegato ai dati reali**
|
|
||||||
- Le azioni registrate in `scout.tsx` devono scrivere sulle tabelle eventi/statistiche.
|
|
||||||
- Mantenere il lock di modifica singolo e l'attivazione solo il giorno della partita.
|
|
||||||
|
|
||||||
6. **Classifica CSI**
|
|
||||||
- Tabella `classifica` aggiornata manualmente da un admin o importata dal sito CSI quando disponibile.
|
|
||||||
- Per ora nessuna API CSI ufficiale: si inserisce a mano o si copia/incolla.
|
|
||||||
|
|
||||||
7. **Notifiche push definitive**
|
|
||||||
- Verificare che i cron job inviino correttamente i promemoria palloni.
|
|
||||||
- Aggiungere notifiche per conferma eventi, promemoria presenze, MVP votabile.
|
|
||||||
|
|
||||||
8. **Ruoli e permessi**
|
|
||||||
- Definire chi può creare/modificare eventi (capitano/admin).
|
|
||||||
- Chi può fare scout (designato per partita).
|
|
||||||
- Chi può modificare i turni palloni (tutti, come da tua richiesta).
|
|
||||||
|
|
||||||
## Cosa resta salvato nel Cloud
|
|
||||||
|
|
||||||
Sì: tutto ciò che viene scritto sulle tabelle Lovable Cloud/Supabase resta salvato online e condiviso tra tutti i dispositivi.
|
|
||||||
|
|
||||||
I dati demo in `src/lib/crapp-data.ts` invece no: sono file statici, quindi ogni aggiornamento dell'app li sovrascrive e ogni telefono li vede identici.
|
|
||||||
|
|
||||||
## Decisioni da prendere insieme
|
|
||||||
|
|
||||||
- Vuoi abilitare login email/password per ogni giocatore, o preferisci mantenere la selezione "Chi sei?" senza password per semplicità?
|
|
||||||
- Chi gestirà inserimento eventi e aggiornamento classifica: solo alcuni o tutta la squadra?
|
|
||||||
- Vuoi procedere per fasi (prima rosa + calendario + presenze, poi statistiche) o tutto insieme?
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
# Ridimensionamento badge nella lista squadra
|
|
||||||
|
|
||||||
## Obiettivo
|
|
||||||
|
|
||||||
Rendere i badge accanto al nome del giocatore nella lista squadra più compatti e meno invasivi, mantenendo lo stile stilizzato (icone Lucide colorate per grado) e lasciando la scheda espansa con una dimensione leggibile.
|
|
||||||
|
|
||||||
## Modifiche previste
|
|
||||||
|
|
||||||
1. **Lista squadra (`src/routes/squadra.tsx`)**
|
|
||||||
- Ridurre le icone badge sbloccati mostrate accanto al nome da `h-4 w-4` (16px) a `h-3 w-3` (12px).
|
|
||||||
- Mantenere il massimo di 3 badge visibili e il contatore `+N` con testo ridotto a `text-[9px]` per armonizzare.
|
|
||||||
- Lasciare invariati avatar, nome, ruolo ed età.
|
|
||||||
|
|
||||||
2. **Scheda giocatore espansa (`src/routes/squadra.tsx`)**
|
|
||||||
- Portare le icone badge dalla dimensione attuale a `h-4 w-4` (16px), leggibili ma non troppo grandi.
|
|
||||||
- Mantenere card, colori per grado (bronzo/argento/oro) e testi descrittivi.
|
|
||||||
|
|
||||||
3. **Verifica**
|
|
||||||
- Controllare la preview su `/squadra` per confermare che i badge in lista siano discreti e la scheda espansa rimanga leggibile.
|
|
||||||
- Eseguire build per assicurarsi che non ci siano errori di tipo o stile.
|
|
||||||
|
|
||||||
## Cosa non cambia
|
|
||||||
|
|
||||||
- Colori dei gradi, soglie badge, logica di sblocco e votazione MVP.
|
|
||||||
- Layout generale della pagina e bottom navigation.
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Rimuovere placeholder "Livello 7" dal Profilo
|
|
||||||
|
|
||||||
## Obiettivo
|
|
||||||
|
|
||||||
Eliminare il testo statico "Livello 7" dalla scheda profilo, dato che non è collegato a nessun calcolo reale e l'utente preferisce toglierlo per ora.
|
|
||||||
|
|
||||||
## Modifica
|
|
||||||
|
|
||||||
- `src/routes/profilo.tsx`: rimuovere il paragrafo `<p className="font-display text-2xl leading-none">Livello 7</p>` (riga 116) e, se necessario, riallineare il layout circostante per evitare spazi vuoti strani.
|
|
||||||
|
|
||||||
## Verifica
|
|
||||||
|
|
||||||
- Build senza errori.
|
|
||||||
- Preview della pagina Profilo: nessun riferimento a "Livello" visibile.
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
# Selezione giocatore al primo avvio
|
|
||||||
|
|
||||||
Aggiungere un flusso di onboarding che chiede "Chi sei?" la prima volta che l'app viene aperta, memorizzando la scelta in `localStorage`. Il profilo e la home si aggiorneranno automaticamente in base al giocatore selezionato.
|
|
||||||
|
|
||||||
## Cosa cambia
|
|
||||||
|
|
||||||
1. **Nuovo store `src/lib/user-store.ts`**
|
|
||||||
- Persiste in `localStorage` l'`id` del giocatore scelto.
|
|
||||||
- Espone `useGiocatoreCorrente()` che restituisce il giocatore selezionato o `null`.
|
|
||||||
- Espone `impostaGiocatore(id)` e `resetGiocatore()`.
|
|
||||||
|
|
||||||
2. **Nuova route `/benvenuto`**
|
|
||||||
- Schermata full-screen con logo, titolo "Benvenuto in CrAPP" e lista scrollabile della rosa.
|
|
||||||
- Ogni riga mostra iniziali, nome, ruolo e numero maglia.
|
|
||||||
- Al tap su un giocatore, lo store viene aggiornato e l'utente viene portato a `/`.
|
|
||||||
- Non mostra la bottom navigation.
|
|
||||||
|
|
||||||
3. **Reindirizzamento condizionato in `__root.tsx`**
|
|
||||||
- Se non è ancora stato selezionato un giocatore, qualunque route apre `/benvenuto`.
|
|
||||||
- Dopo la scelta, l'app funziona normalmente.
|
|
||||||
|
|
||||||
4. **Sostituzione di `giocatoreCorrente` con `useGiocatoreCorrente()`**
|
|
||||||
- Aggiornare `src/routes/index.tsx` per salutare il giocatore selezionato e mostrarne le statistiche rapide.
|
|
||||||
- Aggiornare `src/routes/profilo.tsx` per renderlo il profilo personale del giocatore scelto.
|
|
||||||
|
|
||||||
5. **Cambio utente dalle impostazioni**
|
|
||||||
- In `src/routes/profilo.tsx`, aggiungere una voce "Cambia giocatore" che resetta la selezione e porta a `/benvenuto`.
|
|
||||||
|
|
||||||
## Note tecniche
|
|
||||||
|
|
||||||
- `localStorage` viene letto solo lato client, usando `useSyncExternalStore` per evitare mismatch di hydration.
|
|
||||||
- La rosa reale è già presente in `src/lib/crapp-data.ts` (`giocatori`).
|
|
||||||
- La costante esportata `giocatoreCorrente` verrà rimossa; i componenti consumeranno il nuovo hook.
|
|
||||||
- Nessun backend richiesto: resta un prototipo locale.
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
# Turno palloni nel calendario + promemoria
|
|
||||||
|
|
||||||
Aggiungere a ogni allenamento/partita un incaricato dei palloni, condiviso tra tutti, con rotazione automatica proposta dall'app e promemoria (in-app e push).
|
|
||||||
|
|
||||||
## Cosa vedrà la squadra
|
|
||||||
|
|
||||||
- **Riga "Palloni" su ogni evento** (allenamento e partita) nella card del calendario e in Home: avatar + nome dell'incaricato, oppure "Da assegnare".
|
|
||||||
- **Chiunque può cambiarlo**: tocco sulla riga, si apre la lista della rosa, si sceglie il nome. La modifica è immediata e visibile a tutti.
|
|
||||||
- **Proposta automatica a rotazione**: l'app suggerisce chi non ha ancora fatto il turno di recente (o è stato meno volte incaricato). Il suggerimento è solo una proposta: resta sempre modificabile.
|
|
||||||
- **Storico turni** nella scheda squadra/giocatore: quante volte ciascuno ha portato i palloni.
|
|
||||||
- **Due promemoria per l'incaricato**:
|
|
||||||
1. il giorno stesso dell'evento in cui li deve **prendere** a fine allenamento/partita;
|
|
||||||
2. il giorno dell'evento successivo, per ricordargli di **riportarli**.
|
|
||||||
- I promemoria arrivano come banner ben visibile in Home e, per chi attiva le notifiche, come notifica push sul telefono.
|
|
||||||
|
|
||||||
## Impostazione tecnica
|
|
||||||
|
|
||||||
**Backend (Lovable Cloud)**
|
|
||||||
|
|
||||||
- Attivazione di Lovable Cloud.
|
|
||||||
- Tabella `eventi` (spostando i dati demo attuali su database) o, in alternativa minima, tabella `turni_palloni` con `evento_id`, `giocatore_id`, `aggiornato_da`, `aggiornato_il`. Scelgo la seconda per limitare il refactor: gli eventi restano in `crapp-data.ts` finché non si passa a calendario dinamico.
|
|
||||||
- Tabella `push_subscriptions` (giocatore_id, endpoint, chiavi) per le notifiche.
|
|
||||||
- Grant espliciti + RLS: lettura e scrittura aperte a tutti gli utenti dell'app (nessun login previsto oggi → policy per `anon` limitate a queste tabelle, nessun dato personale sensibile).
|
|
||||||
- Server functions in `src/lib/palloni.functions.ts`: `getTurni`, `setTurno`, `suggerisciTurno`.
|
|
||||||
|
|
||||||
**Frontend**
|
|
||||||
|
|
||||||
- Nuovo componente `TurnoPalloni` usato in `EventoCard` e in Home.
|
|
||||||
- Lettura via TanStack Query (`ensureQueryData` nel loader, `useSuspenseQuery` nel componente), invalidazione dopo la modifica.
|
|
||||||
- Banner promemoria in Home basato su data odierna + evento successivo, mostrato solo al giocatore selezionato in `user-store`.
|
|
||||||
|
|
||||||
**Notifiche push**
|
|
||||||
|
|
||||||
- Service worker dedicato al messaging (separato dalla PWA esistente), chiavi VAPID salvate come secret.
|
|
||||||
- Schermata in Profilo: "Attiva notifiche palloni" con richiesta di permesso.
|
|
||||||
- Invio schedulato tramite un endpoint `src/routes/api/public/promemoria-palloni.ts` protetto da secret, richiamato una volta al giorno da un job pianificato (pg_cron).
|
|
||||||
- Nota: su iPhone le notifiche push funzionano solo se l'app è installata dalla schermata Home.
|
|
||||||
|
|
||||||
## Ordine di lavoro
|
|
||||||
|
|
||||||
1. Attivare Lovable Cloud e creare tabelle + policy.
|
|
||||||
2. Server functions + UI del turno palloni (assegnazione manuale condivisa).
|
|
||||||
3. Rotazione automatica suggerita + storico turni.
|
|
||||||
4. Banner promemoria in-app.
|
|
||||||
5. Notifiche push + job giornaliero.
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"template": "tanstack_start_ts_current",
|
|
||||||
"revision": "tanstack_start_ts_current-9e5645c506e5"
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "crapp",
|
"name": "crapp",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lovable.dev/cloud-auth-js": "^1.1.2",
|
|
||||||
"@supabase/supabase-js": "^2.111.0",
|
"@supabase/supabase-js": "^2.111.0",
|
||||||
"@tailwindcss/vite": "^4.2.1",
|
"@tailwindcss/vite": "^4.2.1",
|
||||||
"@tanstack/react-query": "^5.101.1",
|
"@tanstack/react-query": "^5.101.1",
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.32.0",
|
"@eslint/js": "^9.32.0",
|
||||||
"@lovable.dev/vite-tanstack-config": "2.8.5",
|
"@tanstack/devtools-vite": "^0.8.3",
|
||||||
"@types/canvas-confetti": "^1.9.0",
|
"@types/canvas-confetti": "^1.9.0",
|
||||||
"@types/node": "^22.16.5",
|
"@types/node": "^22.16.5",
|
||||||
"@types/react": "^19.2.0",
|
"@types/react": "^19.2.0",
|
||||||
@@ -130,14 +129,6 @@
|
|||||||
|
|
||||||
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
|
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
|
||||||
|
|
||||||
"@lovable.dev/cloud-auth-js": ["@lovable.dev/cloud-auth-js@1.1.2", "https://europe-west4-npm.pkg.dev/lovable-core-prod/sandbox-npm-cache/@lovable.dev/cloud-auth-js/-/cloud-auth-js-1.1.2.tgz", {}, "sha512-xz8ocewsgwkp8giau272/eWWU3XrchCg5uba4yQPPYtevHTXaVU3sD+fO1JjyPBHacVcOcwhmgUiU9TKHt63cg=="],
|
|
||||||
|
|
||||||
"@lovable.dev/vite-plugin-dev-server-bridge": ["@lovable.dev/vite-plugin-dev-server-bridge@1.2.1", "", { "peerDependencies": { "vite": ">=5.0.0 <9.0.0" } }, "sha512-JdADRwpEJA5t0ggXbd96dND23Wsp69Af9lVSV5m7MnMGxJZlPgqAqz7HUKcfJESfI5M5yFZOl9e0x76JMMDOAg=="],
|
|
||||||
|
|
||||||
"@lovable.dev/vite-plugin-hmr-gate": ["@lovable.dev/vite-plugin-hmr-gate@1.3.5", "https://europe-west1-npm.pkg.dev/lovable-core-prod/sandbox-npm-cache/@lovable.dev/vite-plugin-hmr-gate/-/vite-plugin-hmr-gate-1.3.5.tgz", { "peerDependencies": { "vite": ">=5.0.0 <9.0.0" } }, "sha512-LxCj6JIbYRQ6peMm2aVn/bhHLkwZ5eZ4Cn6gmh7LfjaplqZHlA24nhCowgt6ZLfbckc4d8tSy0He7H8EiFEXag=="],
|
|
||||||
|
|
||||||
"@lovable.dev/vite-tanstack-config": ["@lovable.dev/vite-tanstack-config@2.8.5", "https://europe-west1-npm.pkg.dev/lovable-core-prod/sandbox-npm-cache/@lovable.dev/vite-tanstack-config/-/vite-tanstack-config-2.8.5.tgz", { "dependencies": { "@lovable.dev/vite-plugin-dev-server-bridge": "^1.2.1", "@lovable.dev/vite-plugin-hmr-gate": "^1.3.4", "@tanstack/devtools-vite": "^0.8.1", "lightningcss": "^1.30.0" }, "peerDependencies": { "@tailwindcss/vite": ">=4.0.0", "@tanstack/react-start": ">=1.100.0", "@vitejs/plugin-react": ">=4.0.0", "nitro": ">=3.0.260603-beta", "vite": ">=5.0.0 <9.0.0", "vite-tsconfig-paths": ">=6.0.0" }, "optionalPeers": ["nitro"] }, "sha512-qPNxEXjvRsrbJHKgHxuLWpRW/gu2nIM+62qjTUCbCno5nRPMKyJQNsgjh48qjAkS6T0MRIkY/3BENNXeGsi5hw=="],
|
|
||||||
|
|
||||||
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.2.0", "", { "dependencies": { "@tybys/wasm-util": "^0.10.3" }, "peerDependencies": { "@emnapi/core": "^2.0.0-alpha.3", "@emnapi/runtime": "^2.0.0-alpha.3" } }, "sha512-kDoONqMa+VnZ4vvvu/ZUurpJ4gkZU57e7g69qpNgWhYcZFPUHZM2CEMKm+cG6ufDVALbjMvfmMjFVqaK7uEMnA=="],
|
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.2.0", "", { "dependencies": { "@tybys/wasm-util": "^0.10.3" }, "peerDependencies": { "@emnapi/core": "^2.0.0-alpha.3", "@emnapi/runtime": "^2.0.0-alpha.3" } }, "sha512-kDoONqMa+VnZ4vvvu/ZUurpJ4gkZU57e7g69qpNgWhYcZFPUHZM2CEMKm+cG6ufDVALbjMvfmMjFVqaK7uEMnA=="],
|
||||||
|
|
||||||
"@oozcitak/dom": ["@oozcitak/dom@2.0.2", "", { "dependencies": { "@oozcitak/infra": "^2.0.2", "@oozcitak/url": "^3.0.0", "@oozcitak/util": "^10.0.0" } }, "sha512-GjpKhkSYC3Mj4+lfwEyI1dqnsKTgwGy48ytZEhm4A/xnH/8z9M3ZVXKr/YGQi3uCLs1AEBS+x5T2JPiueEDW8w=="],
|
"@oozcitak/dom": ["@oozcitak/dom@2.0.2", "", { "dependencies": { "@oozcitak/infra": "^2.0.2", "@oozcitak/url": "^3.0.0", "@oozcitak/util": "^10.0.0" } }, "sha512-GjpKhkSYC3Mj4+lfwEyI1dqnsKTgwGy48ytZEhm4A/xnH/8z9M3ZVXKr/YGQi3uCLs1AEBS+x5T2JPiueEDW8w=="],
|
||||||
@@ -424,7 +415,7 @@
|
|||||||
|
|
||||||
"canvas-confetti": ["canvas-confetti@1.9.4", "https://europe-west1-npm.pkg.dev/lovable-core-prod/sandbox-npm-cache/canvas-confetti/-/canvas-confetti-1.9.4.tgz", {}, "sha512-yxQbJkAVrFXWNbTUjPqjF7G+g6pDotOUHGbkZq2NELZUMDpiJ85rIEazVb8GTaAptNW2miJAXbs1BtioA251Pw=="],
|
"canvas-confetti": ["canvas-confetti@1.9.4", "https://europe-west1-npm.pkg.dev/lovable-core-prod/sandbox-npm-cache/canvas-confetti/-/canvas-confetti-1.9.4.tgz", {}, "sha512-yxQbJkAVrFXWNbTUjPqjF7G+g6pDotOUHGbkZq2NELZUMDpiJ85rIEazVb8GTaAptNW2miJAXbs1BtioA251Pw=="],
|
||||||
|
|
||||||
"chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
|
"chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
|
||||||
|
|
||||||
"chokidar": ["chokidar@5.0.0", "", { "dependencies": { "readdirp": "^5.0.0" } }, "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw=="],
|
"chokidar": ["chokidar@5.0.0", "", { "dependencies": { "readdirp": "^5.0.0" } }, "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw=="],
|
||||||
|
|
||||||
@@ -800,10 +791,6 @@
|
|||||||
|
|
||||||
"@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
"@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
||||||
|
|
||||||
"@tanstack/devtools-bundler-core/chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
|
|
||||||
|
|
||||||
"@tanstack/devtools-vite/chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
|
|
||||||
|
|
||||||
"@tanstack/router-generator/zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
|
"@tanstack/router-generator/zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
|
||||||
|
|
||||||
"@tanstack/router-plugin/zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
|
"@tanstack/router-plugin/zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
|
||||||
@@ -820,6 +807,8 @@
|
|||||||
|
|
||||||
"@typescript-eslint/visitor-keys/eslint-visitor-keys": ["eslint-visitor-keys@5.0.1", "", {}, "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA=="],
|
"@typescript-eslint/visitor-keys/eslint-visitor-keys": ["eslint-visitor-keys@5.0.1", "", {}, "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA=="],
|
||||||
|
|
||||||
|
"eslint/chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
|
||||||
|
|
||||||
"h3/srvx": ["srvx@0.12.4", "", { "bin": { "srvx": "bin/srvx.mjs" } }, "sha512-RixzFlMn3dvzDTpKIAXhXrqL4cy6vScNCP0VVwgVbUBU94o+DiXLsFnAZetbyKAEnK6Ox3hzHXWGsyv/Iibv7g=="],
|
"h3/srvx": ["srvx@0.12.4", "", { "bin": { "srvx": "bin/srvx.mjs" } }, "sha512-RixzFlMn3dvzDTpKIAXhXrqL4cy6vScNCP0VVwgVbUBU94o+DiXLsFnAZetbyKAEnK6Ox3hzHXWGsyv/Iibv7g=="],
|
||||||
|
|
||||||
"h3-v2/rou3": ["rou3@0.8.1", "", {}, "sha512-ePa+XGk00/3HuCqrEnK3LxJW7I0SdNg6EFzKUJG73hMAdDcOUC/i/aSz7LSDwLrGr33kal/rqOGydzwl6U7zBA=="],
|
"h3-v2/rou3": ["rou3@0.8.1", "", {}, "sha512-ePa+XGk00/3HuCqrEnK3LxJW7I0SdNg6EFzKUJG73hMAdDcOUC/i/aSz7LSDwLrGr33kal/rqOGydzwl6U7zBA=="],
|
||||||
|
|||||||
+1
-1
@@ -4,4 +4,4 @@ saveTextLockfile = true
|
|||||||
minimumReleaseAge = 86400
|
minimumReleaseAge = 86400
|
||||||
# Each entry bypasses the 24h guard for one package — confirm with the user
|
# Each entry bypasses the 24h guard for one package — confirm with the user
|
||||||
# before adding any.
|
# before adding any.
|
||||||
minimumReleaseAgeExcludes = ["@lovable.dev/vite-tanstack-config", "@lovable.dev/mcp-js", "@lovable.dev/vite-plugin-dev-server-bridge", "@lovable.dev/vite-plugin-hmr-gate", "@lovable.dev/email-js", "@lovable.dev/webhooks-js"]
|
minimumReleaseAgeExcludes = []
|
||||||
|
|||||||
@@ -12,6 +12,34 @@ all'indietro.
|
|||||||
|
|
||||||
## [Non rilasciato]
|
## [Non rilasciato]
|
||||||
|
|
||||||
|
## [0.9.2] - 2026-09-10
|
||||||
|
|
||||||
|
### Aggiunto
|
||||||
|
|
||||||
|
- **Dashboard amministratore** — nuova tab "Notifiche" che mostra quanti giocatori hanno
|
||||||
|
le notifiche push attive e chi sono.
|
||||||
|
|
||||||
|
### Modificato
|
||||||
|
|
||||||
|
- **Dashboard amministratore** — le sezioni impilate diventano un menu di tab scorrevole a
|
||||||
|
pillole (come Squadra e Campionato); nell'elenco Profili resta aperta una sola scheda
|
||||||
|
alla volta.
|
||||||
|
- **Profilo** — testi dei campi amministrativi semplificati (label email, rimossa la nota
|
||||||
|
su chi vede quei dati).
|
||||||
|
|
||||||
|
### Rimosso
|
||||||
|
|
||||||
|
- Le dipendenze e il codice legati all'editor Lovable (login social e reporting errori
|
||||||
|
verso l'editor): l'app non ci gira più.
|
||||||
|
|
||||||
|
## [0.9.1] - 2026-09-10
|
||||||
|
|
||||||
|
### Modificato
|
||||||
|
|
||||||
|
- **Storico partite** — ogni scheda mostra il logo accanto al nome di entrambe le squadre
|
||||||
|
(CRAP e avversario), risultato e parziali in ordine casa–ospite (verde/rosso restano
|
||||||
|
vittoria/sconfitta CRAP) e un chevron a destra per chiarire che la riga apre il dettaglio.
|
||||||
|
|
||||||
## [0.9.0] - 2026-09-09
|
## [0.9.0] - 2026-09-09
|
||||||
|
|
||||||
Prima versione pre-release: lo sviluppo precedente non era versionato a parte, quindi
|
Prima versione pre-release: lo sviluppo precedente non era versionato a parte, quindi
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ senza dipendere da servizi esclusivi di Lovable Cloud.
|
|||||||
| Client dati (`@supabase/supabase-js`) | Sì | Supabase è open source e self-hostable; in alternativa si sostituisce il solo livello dati (`src/lib/*.ts`). |
|
| Client dati (`@supabase/supabase-js`) | Sì | Supabase è open source e self-hostable; in alternativa si sostituisce il solo livello dati (`src/lib/*.ts`). |
|
||||||
| Web Push (`src/lib/webpush.server.ts`) | Sì | VAPID implementato con Web Crypto, disponibile in Node 18+. |
|
| Web Push (`src/lib/webpush.server.ts`) | Sì | VAPID implementato con Web Crypto, disponibile in Node 18+. |
|
||||||
| Auth | Sì | GoTrue self-hosted oppure qualsiasi provider OIDC. |
|
| Auth | Sì | GoTrue self-hosted oppure qualsiasi provider OIDC. |
|
||||||
| `src/integrations/lovable/*` | Opzionale | Login social gestito da Lovable: **non importato da nessuna schermata**, rimovibile senza impatti. |
|
|
||||||
| `@lovable.dev/vite-tanstack-config` | Solo build | Preset Vite; sostituibile con una config Vite/TanStack esplicita. |
|
| `@lovable.dev/vite-tanstack-config` | Solo build | Preset Vite; sostituibile con una config Vite/TanStack esplicita. |
|
||||||
|
|
||||||
## Regole da rispettare nelle prossime modifiche
|
## Regole da rispettare nelle prossime modifiche
|
||||||
|
|||||||
@@ -154,7 +154,8 @@ CSI (portale)
|
|||||||
useCsi() → src/lib/csi.ts (React Query, staleTime 6h)
|
useCsi() → src/lib/csi.ts (React Query, staleTime 6h)
|
||||||
↓
|
↓
|
||||||
/classifica → src/routes/classifica.tsx (tab "Classifica": Coppa sopra, Girone
|
/classifica → src/routes/classifica.tsx (tab "Classifica": Coppa sopra, Girone
|
||||||
sotto; tab "Storico partite": ogni gara cliccabile)
|
sotto; tab "Storico partite": ogni squadra col proprio logo,
|
||||||
|
chevron di dettaglio sulle gare cliccabili)
|
||||||
|
|
||||||
CSI (portale, 3 endpoint)
|
CSI (portale, 3 endpoint)
|
||||||
↓ fetch server-side on-demand, cache per-partita 6 ore
|
↓ fetch server-side on-demand, cache per-partita 6 ore
|
||||||
|
|||||||
@@ -82,10 +82,14 @@ route. Tutte e tre partono da un gesto di un amministratore dentro l'app, quindi
|
|||||||
variabile d'ambiente.
|
variabile d'ambiente.
|
||||||
|
|
||||||
| Route | Controllo | Chi la chiama |
|
| Route | Controllo | Chi la chiama |
|
||||||
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- |
|
| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- |
|
||||||
| `apri-sondaggio`, `sollecita-presenze`, `promemoria-palloni` | `richiediAdmin` — token della sessione Supabase, poi ruolo `admin` in `user_roles` | l'app, da un pulsante riservato agli admin |
|
| `apri-sondaggio`, `sollecita-presenze`, `promemoria-palloni`, `notifiche-attive` | `richiediAdmin` — token della sessione Supabase, poi ruolo `admin` in `user_roles` | l'app, da un pulsante o una vista riservati agli admin |
|
||||||
| `csi`, `push-config`, `push-subscribe` | nessuno | il browser prima del login, che una sessione non ce l'ha ancora |
|
| `csi`, `push-config`, `push-subscribe` | nessuno | il browser prima del login, che una sessione non ce l'ha ancora |
|
||||||
|
|
||||||
|
`notifiche-attive` è a sola lettura: non manda push, restituisce gli id giocatore con almeno
|
||||||
|
un dispositivo iscritto in `push_subscriptions` (deduplicati). Alimenta la tab "Notifiche"
|
||||||
|
della dashboard admin (vedi [Profilo giocatore](profilo-giocatore.md)), non l'invio effettivo.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Notifiche smart
|
## Notifiche smart
|
||||||
|
|||||||
@@ -165,9 +165,17 @@ Contiene.
|
|||||||
## Dashboard amministratore
|
## Dashboard amministratore
|
||||||
|
|
||||||
Gli amministratori dispongono di una schermata dedicata (`/admin`, raggiungibile da
|
Gli amministratori dispongono di una schermata dedicata (`/admin`, raggiungibile da
|
||||||
Profilo → Opzioni).
|
Profilo → Opzioni), organizzata in tab scorrevoli a pillole (`BarraSottosezioni`, stesso
|
||||||
|
componente di [Squadra](squadra.md) e Campionato): Squadra, Profili, Disattivati (solo se
|
||||||
|
c'è almeno un giocatore disattivato) e Notifiche.
|
||||||
|
|
||||||
Per ogni giocatore vengono mostrati.
|
La tab **Notifiche** mostra quanti giocatori attivi hanno almeno un dispositivo iscritto
|
||||||
|
alle notifiche push e i loro nomi, leggendo `GET /api/public/notifiche-attive` (vedi
|
||||||
|
[Notifiche](notifiche.md)). È solo consultiva: l'attivazione resta un gesto che ogni
|
||||||
|
giocatore deve fare dal proprio dispositivo (Profilo), l'admin non può attivarla per conto
|
||||||
|
di altri.
|
||||||
|
|
||||||
|
Per ogni giocatore, nella tab Profili, vengono mostrati.
|
||||||
|
|
||||||
- Stato del profilo
|
- Stato del profilo
|
||||||
- Certificato medico
|
- Certificato medico
|
||||||
|
|||||||
+2
-3
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "crapp",
|
"name": "crapp",
|
||||||
"version": "0.9.0",
|
"version": "0.9.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
"test:all": "bun test/run.ts all"
|
"test:all": "bun test/run.ts all"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lovable.dev/cloud-auth-js": "^1.1.2",
|
|
||||||
"@supabase/supabase-js": "^2.111.0",
|
"@supabase/supabase-js": "^2.111.0",
|
||||||
"@tailwindcss/vite": "^4.2.1",
|
"@tailwindcss/vite": "^4.2.1",
|
||||||
"@tanstack/react-query": "^5.101.1",
|
"@tanstack/react-query": "^5.101.1",
|
||||||
@@ -39,7 +38,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.32.0",
|
"@eslint/js": "^9.32.0",
|
||||||
"@lovable.dev/vite-tanstack-config": "2.8.5",
|
"@tanstack/devtools-vite": "^0.8.3",
|
||||||
"@types/canvas-confetti": "^1.9.0",
|
"@types/canvas-confetti": "^1.9.0",
|
||||||
"@types/node": "^22.16.5",
|
"@types/node": "^22.16.5",
|
||||||
"@types/react": "^19.2.0",
|
"@types/react": "^19.2.0",
|
||||||
|
|||||||
@@ -304,10 +304,6 @@ export function ProfiloAmministrativo({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
Servono agli amministratori per il tesseramento CSI. Li vedi solo tu e loro.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<CampiProfilo
|
<CampiProfilo
|
||||||
corrente={corrente}
|
corrente={corrente}
|
||||||
aggiorna={aggiorna}
|
aggiorna={aggiorna}
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
// This file is auto-generated by Lovable. Do not modify it.
|
|
||||||
|
|
||||||
import { createLovableAuth } from "@lovable.dev/cloud-auth-js";
|
|
||||||
import { supabase } from "../supabase/client";
|
|
||||||
const lovableAuth = createLovableAuth();
|
|
||||||
|
|
||||||
type SignInOptions = {
|
|
||||||
redirect_uri?: string;
|
|
||||||
extraParams?: Record<string, string>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const lovable = {
|
|
||||||
auth: {
|
|
||||||
signInWithOAuth: async (
|
|
||||||
provider: "google" | "apple" | "microsoft" | "lovable",
|
|
||||||
opts?: SignInOptions,
|
|
||||||
) => {
|
|
||||||
const result = await lovableAuth.signInWithOAuth(provider, {
|
|
||||||
redirect_uri: opts?.redirect_uri ?? window.location.origin,
|
|
||||||
extraParams: {
|
|
||||||
...opts?.extraParams,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result.redirected) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.error) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await supabase.auth.setSession(result.tokens);
|
|
||||||
} catch (e) {
|
|
||||||
return { error: e instanceof Error ? e : new Error(String(e)) };
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
type LovableErrorOptions = {
|
|
||||||
mechanism?: "manual" | "onerror" | "unhandledrejection" | "react_error_boundary";
|
|
||||||
handled?: boolean;
|
|
||||||
severity?: "error" | "warning" | "info";
|
|
||||||
};
|
|
||||||
|
|
||||||
type LovableEvents = {
|
|
||||||
captureException?: (
|
|
||||||
error: unknown,
|
|
||||||
context?: Record<string, unknown>,
|
|
||||||
options?: LovableErrorOptions,
|
|
||||||
) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
interface Window {
|
|
||||||
__lovableEvents?: LovableEvents;
|
|
||||||
__lovableReportRuntimeError?: (payload: {
|
|
||||||
message: string;
|
|
||||||
stack?: string;
|
|
||||||
filename?: string;
|
|
||||||
}) => void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function reportLovableError(error: unknown, context: Record<string, unknown> = {}) {
|
|
||||||
if (typeof window === "undefined") return;
|
|
||||||
window.__lovableEvents?.captureException?.(
|
|
||||||
error,
|
|
||||||
{
|
|
||||||
source: "react_error_boundary",
|
|
||||||
route: window.location.pathname,
|
|
||||||
...context,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
mechanism: "react_error_boundary",
|
|
||||||
handled: false,
|
|
||||||
severity: "error",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
// Prod React does not rethrow boundary-caught errors to window.onerror, so the
|
|
||||||
// editor's telemetry never sees them. Forward to lovable.js's reporting hook,
|
|
||||||
// which is present only inside the editor preview.
|
|
||||||
// Loaders and server fns commonly throw a raw Response; String(it) is the
|
|
||||||
// opaque "[object Response]", so pull out the status and URL instead.
|
|
||||||
const message =
|
|
||||||
error instanceof Response
|
|
||||||
? `Response ${error.status}${error.url ? ` at ${error.url}` : ""}`
|
|
||||||
: error instanceof Error
|
|
||||||
? error.message
|
|
||||||
: String(error);
|
|
||||||
const stack = error instanceof Error ? error.stack : undefined;
|
|
||||||
window.__lovableReportRuntimeError?.({
|
|
||||||
message,
|
|
||||||
...(stack !== undefined && { stack }),
|
|
||||||
filename: window.location.pathname,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { intestazioniAutenticate } from "./auth";
|
||||||
|
|
||||||
|
const NOTIFICHE_ATTIVE_KEY = ["notifiche-attive"] as const;
|
||||||
|
|
||||||
|
async function fetchNotificheAttive(): Promise<Set<string>> {
|
||||||
|
const res = await fetch("/api/public/notifiche-attive", {
|
||||||
|
headers: await intestazioniAutenticate(),
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error("Impossibile leggere le notifiche attive");
|
||||||
|
const { giocatoreIds } = (await res.json()) as { giocatoreIds: string[] };
|
||||||
|
return new Set(giocatoreIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Insieme degli id giocatore con almeno un dispositivo iscritto alle notifiche push. */
|
||||||
|
export function useNotificheAttive() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: NOTIFICHE_ATTIVE_KEY,
|
||||||
|
queryFn: fetchNotificheAttive,
|
||||||
|
staleTime: 5 * 60_000,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/** Id giocatore distinti tra le righe di `push_subscriptions` (una riga per dispositivo). */
|
||||||
|
export function idsConNotificheAttive(righe: Array<{ giocatore_id: string }>): string[] {
|
||||||
|
return [...new Set(righe.map((r) => r.giocatore_id))];
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ import { Route as PartitaCsiIdRouteImport } from './routes/partita-csi.$id'
|
|||||||
import { Route as PartitaIdRouteImport } from './routes/partita.$id'
|
import { Route as PartitaIdRouteImport } from './routes/partita.$id'
|
||||||
import { Route as ApiPublicApriSondaggioRouteImport } from './routes/api/public/apri-sondaggio'
|
import { Route as ApiPublicApriSondaggioRouteImport } from './routes/api/public/apri-sondaggio'
|
||||||
import { Route as ApiPublicCsiRouteImport } from './routes/api/public/csi'
|
import { Route as ApiPublicCsiRouteImport } from './routes/api/public/csi'
|
||||||
|
import { Route as ApiPublicNotificheAttiveRouteImport } from './routes/api/public/notifiche-attive'
|
||||||
import { Route as ApiPublicPromemoriaPalloniRouteImport } from './routes/api/public/promemoria-palloni'
|
import { Route as ApiPublicPromemoriaPalloniRouteImport } from './routes/api/public/promemoria-palloni'
|
||||||
import { Route as ApiPublicPushConfigRouteImport } from './routes/api/public/push-config'
|
import { Route as ApiPublicPushConfigRouteImport } from './routes/api/public/push-config'
|
||||||
import { Route as ApiPublicPushSubscribeRouteImport } from './routes/api/public/push-subscribe'
|
import { Route as ApiPublicPushSubscribeRouteImport } from './routes/api/public/push-subscribe'
|
||||||
@@ -99,6 +100,12 @@ const ApiPublicCsiRoute = ApiPublicCsiRouteImport.update({
|
|||||||
path: '/api/public/csi',
|
path: '/api/public/csi',
|
||||||
getParentRoute: () => rootRouteImport,
|
getParentRoute: () => rootRouteImport,
|
||||||
} as any)
|
} as any)
|
||||||
|
const ApiPublicNotificheAttiveRoute =
|
||||||
|
ApiPublicNotificheAttiveRouteImport.update({
|
||||||
|
id: '/api/public/notifiche-attive',
|
||||||
|
path: '/api/public/notifiche-attive',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
const ApiPublicPromemoriaPalloniRoute =
|
const ApiPublicPromemoriaPalloniRoute =
|
||||||
ApiPublicPromemoriaPalloniRouteImport.update({
|
ApiPublicPromemoriaPalloniRouteImport.update({
|
||||||
id: '/api/public/promemoria-palloni',
|
id: '/api/public/promemoria-palloni',
|
||||||
@@ -142,6 +149,7 @@ export interface FileRoutesByFullPath {
|
|||||||
'/partita/$id': typeof PartitaIdRoute
|
'/partita/$id': typeof PartitaIdRoute
|
||||||
'/api/public/apri-sondaggio': typeof ApiPublicApriSondaggioRoute
|
'/api/public/apri-sondaggio': typeof ApiPublicApriSondaggioRoute
|
||||||
'/api/public/csi': typeof ApiPublicCsiRoute
|
'/api/public/csi': typeof ApiPublicCsiRoute
|
||||||
|
'/api/public/notifiche-attive': typeof ApiPublicNotificheAttiveRoute
|
||||||
'/api/public/promemoria-palloni': typeof ApiPublicPromemoriaPalloniRoute
|
'/api/public/promemoria-palloni': typeof ApiPublicPromemoriaPalloniRoute
|
||||||
'/api/public/push-config': typeof ApiPublicPushConfigRoute
|
'/api/public/push-config': typeof ApiPublicPushConfigRoute
|
||||||
'/api/public/push-subscribe': typeof ApiPublicPushSubscribeRoute
|
'/api/public/push-subscribe': typeof ApiPublicPushSubscribeRoute
|
||||||
@@ -163,6 +171,7 @@ export interface FileRoutesByTo {
|
|||||||
'/partita/$id': typeof PartitaIdRoute
|
'/partita/$id': typeof PartitaIdRoute
|
||||||
'/api/public/apri-sondaggio': typeof ApiPublicApriSondaggioRoute
|
'/api/public/apri-sondaggio': typeof ApiPublicApriSondaggioRoute
|
||||||
'/api/public/csi': typeof ApiPublicCsiRoute
|
'/api/public/csi': typeof ApiPublicCsiRoute
|
||||||
|
'/api/public/notifiche-attive': typeof ApiPublicNotificheAttiveRoute
|
||||||
'/api/public/promemoria-palloni': typeof ApiPublicPromemoriaPalloniRoute
|
'/api/public/promemoria-palloni': typeof ApiPublicPromemoriaPalloniRoute
|
||||||
'/api/public/push-config': typeof ApiPublicPushConfigRoute
|
'/api/public/push-config': typeof ApiPublicPushConfigRoute
|
||||||
'/api/public/push-subscribe': typeof ApiPublicPushSubscribeRoute
|
'/api/public/push-subscribe': typeof ApiPublicPushSubscribeRoute
|
||||||
@@ -185,6 +194,7 @@ export interface FileRoutesById {
|
|||||||
'/partita/$id': typeof PartitaIdRoute
|
'/partita/$id': typeof PartitaIdRoute
|
||||||
'/api/public/apri-sondaggio': typeof ApiPublicApriSondaggioRoute
|
'/api/public/apri-sondaggio': typeof ApiPublicApriSondaggioRoute
|
||||||
'/api/public/csi': typeof ApiPublicCsiRoute
|
'/api/public/csi': typeof ApiPublicCsiRoute
|
||||||
|
'/api/public/notifiche-attive': typeof ApiPublicNotificheAttiveRoute
|
||||||
'/api/public/promemoria-palloni': typeof ApiPublicPromemoriaPalloniRoute
|
'/api/public/promemoria-palloni': typeof ApiPublicPromemoriaPalloniRoute
|
||||||
'/api/public/push-config': typeof ApiPublicPushConfigRoute
|
'/api/public/push-config': typeof ApiPublicPushConfigRoute
|
||||||
'/api/public/push-subscribe': typeof ApiPublicPushSubscribeRoute
|
'/api/public/push-subscribe': typeof ApiPublicPushSubscribeRoute
|
||||||
@@ -208,6 +218,7 @@ export interface FileRouteTypes {
|
|||||||
| '/partita/$id'
|
| '/partita/$id'
|
||||||
| '/api/public/apri-sondaggio'
|
| '/api/public/apri-sondaggio'
|
||||||
| '/api/public/csi'
|
| '/api/public/csi'
|
||||||
|
| '/api/public/notifiche-attive'
|
||||||
| '/api/public/promemoria-palloni'
|
| '/api/public/promemoria-palloni'
|
||||||
| '/api/public/push-config'
|
| '/api/public/push-config'
|
||||||
| '/api/public/push-subscribe'
|
| '/api/public/push-subscribe'
|
||||||
@@ -229,6 +240,7 @@ export interface FileRouteTypes {
|
|||||||
| '/partita/$id'
|
| '/partita/$id'
|
||||||
| '/api/public/apri-sondaggio'
|
| '/api/public/apri-sondaggio'
|
||||||
| '/api/public/csi'
|
| '/api/public/csi'
|
||||||
|
| '/api/public/notifiche-attive'
|
||||||
| '/api/public/promemoria-palloni'
|
| '/api/public/promemoria-palloni'
|
||||||
| '/api/public/push-config'
|
| '/api/public/push-config'
|
||||||
| '/api/public/push-subscribe'
|
| '/api/public/push-subscribe'
|
||||||
@@ -250,6 +262,7 @@ export interface FileRouteTypes {
|
|||||||
| '/partita/$id'
|
| '/partita/$id'
|
||||||
| '/api/public/apri-sondaggio'
|
| '/api/public/apri-sondaggio'
|
||||||
| '/api/public/csi'
|
| '/api/public/csi'
|
||||||
|
| '/api/public/notifiche-attive'
|
||||||
| '/api/public/promemoria-palloni'
|
| '/api/public/promemoria-palloni'
|
||||||
| '/api/public/push-config'
|
| '/api/public/push-config'
|
||||||
| '/api/public/push-subscribe'
|
| '/api/public/push-subscribe'
|
||||||
@@ -272,6 +285,7 @@ export interface RootRouteChildren {
|
|||||||
PartitaIdRoute: typeof PartitaIdRoute
|
PartitaIdRoute: typeof PartitaIdRoute
|
||||||
ApiPublicApriSondaggioRoute: typeof ApiPublicApriSondaggioRoute
|
ApiPublicApriSondaggioRoute: typeof ApiPublicApriSondaggioRoute
|
||||||
ApiPublicCsiRoute: typeof ApiPublicCsiRoute
|
ApiPublicCsiRoute: typeof ApiPublicCsiRoute
|
||||||
|
ApiPublicNotificheAttiveRoute: typeof ApiPublicNotificheAttiveRoute
|
||||||
ApiPublicPromemoriaPalloniRoute: typeof ApiPublicPromemoriaPalloniRoute
|
ApiPublicPromemoriaPalloniRoute: typeof ApiPublicPromemoriaPalloniRoute
|
||||||
ApiPublicPushConfigRoute: typeof ApiPublicPushConfigRoute
|
ApiPublicPushConfigRoute: typeof ApiPublicPushConfigRoute
|
||||||
ApiPublicPushSubscribeRoute: typeof ApiPublicPushSubscribeRoute
|
ApiPublicPushSubscribeRoute: typeof ApiPublicPushSubscribeRoute
|
||||||
@@ -379,6 +393,13 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof ApiPublicCsiRouteImport
|
preLoaderRoute: typeof ApiPublicCsiRouteImport
|
||||||
parentRoute: typeof rootRouteImport
|
parentRoute: typeof rootRouteImport
|
||||||
}
|
}
|
||||||
|
'/api/public/notifiche-attive': {
|
||||||
|
id: '/api/public/notifiche-attive'
|
||||||
|
path: '/api/public/notifiche-attive'
|
||||||
|
fullPath: '/api/public/notifiche-attive'
|
||||||
|
preLoaderRoute: typeof ApiPublicNotificheAttiveRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
'/api/public/promemoria-palloni': {
|
'/api/public/promemoria-palloni': {
|
||||||
id: '/api/public/promemoria-palloni'
|
id: '/api/public/promemoria-palloni'
|
||||||
path: '/api/public/promemoria-palloni'
|
path: '/api/public/promemoria-palloni'
|
||||||
@@ -432,6 +453,7 @@ const rootRouteChildren: RootRouteChildren = {
|
|||||||
PartitaIdRoute: PartitaIdRoute,
|
PartitaIdRoute: PartitaIdRoute,
|
||||||
ApiPublicApriSondaggioRoute: ApiPublicApriSondaggioRoute,
|
ApiPublicApriSondaggioRoute: ApiPublicApriSondaggioRoute,
|
||||||
ApiPublicCsiRoute: ApiPublicCsiRoute,
|
ApiPublicCsiRoute: ApiPublicCsiRoute,
|
||||||
|
ApiPublicNotificheAttiveRoute: ApiPublicNotificheAttiveRoute,
|
||||||
ApiPublicPromemoriaPalloniRoute: ApiPublicPromemoriaPalloniRoute,
|
ApiPublicPromemoriaPalloniRoute: ApiPublicPromemoriaPalloniRoute,
|
||||||
ApiPublicPushConfigRoute: ApiPublicPushConfigRoute,
|
ApiPublicPushConfigRoute: ApiPublicPushConfigRoute,
|
||||||
ApiPublicPushSubscribeRoute: ApiPublicPushSubscribeRoute,
|
ApiPublicPushSubscribeRoute: ApiPublicPushSubscribeRoute,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
import { useEffect, useState, type ReactNode } from "react";
|
import { useEffect, useState, type ReactNode } from "react";
|
||||||
|
|
||||||
import appCss from "../styles.css?url";
|
import appCss from "../styles.css?url";
|
||||||
import { reportLovableError } from "../lib/lovable-error-reporting";
|
|
||||||
import { BottomNav } from "../components/crapp/BottomNav";
|
import { BottomNav } from "../components/crapp/BottomNav";
|
||||||
import { CelebrazioneBadge } from "../components/crapp/CelebrazioneBadge";
|
import { CelebrazioneBadge } from "../components/crapp/CelebrazioneBadge";
|
||||||
import { Toaster } from "../components/ui/sonner";
|
import { Toaster } from "../components/ui/sonner";
|
||||||
@@ -47,9 +46,6 @@ function NotFoundComponent() {
|
|||||||
function ErrorComponent({ error, reset }: { error: Error; reset: () => void }) {
|
function ErrorComponent({ error, reset }: { error: Error; reset: () => void }) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
useEffect(() => {
|
|
||||||
reportLovableError(error, { boundary: "tanstack_root_error_component" });
|
|
||||||
}, [error]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-dvh items-center justify-center bg-background px-4">
|
<div className="flex min-h-dvh items-center justify-center bg-background px-4">
|
||||||
|
|||||||
+71
-33
@@ -2,6 +2,7 @@ import { useState } from "react";
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import {
|
import {
|
||||||
BadgeCheck,
|
BadgeCheck,
|
||||||
|
Bell,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
Download,
|
Download,
|
||||||
FileText,
|
FileText,
|
||||||
@@ -16,14 +17,8 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import {
|
import { Campo, classiInput, PageHeader, Select, StatTile } from "@/components/crapp/ui-bits";
|
||||||
Campo,
|
import { BarraSottosezioni } from "@/components/crapp/BarraSottosezioni";
|
||||||
classiInput,
|
|
||||||
PageHeader,
|
|
||||||
Section,
|
|
||||||
Select,
|
|
||||||
StatTile,
|
|
||||||
} from "@/components/crapp/ui-bits";
|
|
||||||
import { CampiProfilo } from "@/components/crapp/ProfiloAmministrativo";
|
import { CampiProfilo } from "@/components/crapp/ProfiloAmministrativo";
|
||||||
import {
|
import {
|
||||||
nomeCompleto,
|
nomeCompleto,
|
||||||
@@ -54,6 +49,7 @@ import {
|
|||||||
import { oggiISO } from "@/lib/palloni-core";
|
import { oggiISO } from "@/lib/palloni-core";
|
||||||
import { scaricaCsv } from "@/lib/scout-export";
|
import { scaricaCsv } from "@/lib/scout-export";
|
||||||
import { useIsAdmin } from "@/lib/ruoli";
|
import { useIsAdmin } from "@/lib/ruoli";
|
||||||
|
import { useNotificheAttive } from "@/lib/notifiche-admin";
|
||||||
import { Reveal } from "@/components/motion/Reveal";
|
import { Reveal } from "@/components/motion/Reveal";
|
||||||
|
|
||||||
export const Route = createFileRoute("/admin")({
|
export const Route = createFileRoute("/admin")({
|
||||||
@@ -232,7 +228,7 @@ function ModificaGiocatore({ g, profilo }: { g: GiocatoreSquadra; profilo: Profi
|
|||||||
</Select>
|
</Select>
|
||||||
</Campo>
|
</Campo>
|
||||||
</div>
|
</div>
|
||||||
<Campo label="Email (collegamento automatico al login, DD-018)">
|
<Campo label="Email">
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
value={squadraCorrente.email ?? ""}
|
value={squadraCorrente.email ?? ""}
|
||||||
@@ -384,13 +380,16 @@ function SchedaGiocatore({
|
|||||||
profilo,
|
profilo,
|
||||||
oggi,
|
oggi,
|
||||||
indice,
|
indice,
|
||||||
|
aperta,
|
||||||
|
onToggle,
|
||||||
}: {
|
}: {
|
||||||
g: GiocatoreSquadra;
|
g: GiocatoreSquadra;
|
||||||
profilo: Profilo | undefined;
|
profilo: Profilo | undefined;
|
||||||
oggi: string;
|
oggi: string;
|
||||||
indice: number;
|
indice: number;
|
||||||
|
aperta: boolean;
|
||||||
|
onToggle: () => void;
|
||||||
}) {
|
}) {
|
||||||
const [aperta, setAperta] = useState(false);
|
|
||||||
const nome = nomeCompleto(g);
|
const nome = nomeCompleto(g);
|
||||||
const { ruolo, numero } = g;
|
const { ruolo, numero } = g;
|
||||||
const perc = completamento(profilo);
|
const perc = completamento(profilo);
|
||||||
@@ -401,11 +400,7 @@ function SchedaGiocatore({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Reveal indice={indice} className="rounded-2xl bg-card p-4 shadow-card">
|
<Reveal indice={indice} className="rounded-2xl bg-card p-4 shadow-card">
|
||||||
<button
|
<button type="button" onClick={onToggle} className="flex w-full items-center gap-3 text-left">
|
||||||
type="button"
|
|
||||||
onClick={() => setAperta((v) => !v)}
|
|
||||||
className="flex w-full items-center gap-3 text-left"
|
|
||||||
>
|
|
||||||
<div className="grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-secondary font-display text-sm tabular-nums">
|
<div className="grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-secondary font-display text-sm tabular-nums">
|
||||||
{numero}
|
{numero}
|
||||||
</div>
|
</div>
|
||||||
@@ -552,7 +547,7 @@ function AggiungiGiocatore({ righe }: { righe: GiocatoreSquadra[] }) {
|
|||||||
</Select>
|
</Select>
|
||||||
</Campo>
|
</Campo>
|
||||||
</div>
|
</div>
|
||||||
<Campo label="Email (collegamento automatico al login, opzionale)">
|
<Campo label="Email">
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
value={dati.email ?? ""}
|
value={dati.email ?? ""}
|
||||||
@@ -623,6 +618,8 @@ function Dashboard() {
|
|||||||
const admin = useIsAdmin();
|
const admin = useIsAdmin();
|
||||||
const { righe: squadra } = useGiocatoriSquadra();
|
const { righe: squadra } = useGiocatoriSquadra();
|
||||||
const { profili, isPending } = useProfili();
|
const { profili, isPending } = useProfili();
|
||||||
|
const { data: notificheAttive } = useNotificheAttive();
|
||||||
|
const [schedaAperta, setSchedaAperta] = useState<string | null>(null);
|
||||||
const oggi = oggiISO();
|
const oggi = oggiISO();
|
||||||
|
|
||||||
if (!admin) {
|
if (!admin) {
|
||||||
@@ -649,11 +646,8 @@ function Dashboard() {
|
|||||||
).length;
|
).length;
|
||||||
const tesserati = attivi.filter((g) => g.numeroTessera).length;
|
const tesserati = attivi.filter((g) => g.numeroTessera).length;
|
||||||
|
|
||||||
return (
|
const contenutoSquadra = (
|
||||||
<>
|
<>
|
||||||
<PageHeader titolo="Dashboard" sottotitolo="Profili e tesseramento" />
|
|
||||||
|
|
||||||
<Section titolo="Squadra">
|
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<StatTile valore={attivi.length} label="Giocatori" />
|
<StatTile valore={attivi.length} label="Giocatori" />
|
||||||
<StatTile valore={`${completi}/${attivi.length}`} label="Profili completi" />
|
<StatTile valore={`${completi}/${attivi.length}`} label="Profili completi" />
|
||||||
@@ -666,39 +660,83 @@ function Dashboard() {
|
|||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() => scaricaCsv(`tesseramento-csi-${oggi}.csv`, csvTesseramento(attivi, profili))}
|
||||||
scaricaCsv(`tesseramento-csi-${oggi}.csv`, csvTesseramento(attivi, profili))
|
|
||||||
}
|
|
||||||
className="premi mt-3 flex w-full items-center justify-center gap-2 rounded-2xl bg-accent-grad py-3 text-sm font-bold uppercase text-accent-foreground shadow-pop"
|
className="premi mt-3 flex w-full items-center justify-center gap-2 rounded-2xl bg-accent-grad py-3 text-sm font-bold uppercase text-accent-foreground shadow-pop"
|
||||||
>
|
>
|
||||||
<Download className="h-4 w-4" /> Esporta CSV tesseramento
|
<Download className="h-4 w-4" /> Esporta CSV tesseramento
|
||||||
</button>
|
</button>
|
||||||
<AggiungiGiocatore righe={squadra} />
|
<AggiungiGiocatore righe={squadra} />
|
||||||
</Section>
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
<Section titolo="Profili" indice={1}>
|
const contenutoProfili = isPending ? (
|
||||||
{isPending ? (
|
|
||||||
<p className="rounded-2xl bg-card p-5 text-center text-sm text-muted-foreground shadow-card">
|
<p className="rounded-2xl bg-card p-5 text-center text-sm text-muted-foreground shadow-card">
|
||||||
Caricamento…
|
Caricamento…
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{attivi.map((g, i) => (
|
{attivi.map((g, i) => (
|
||||||
<SchedaGiocatore key={g.id} g={g} profilo={profili[g.id]} oggi={oggi} indice={i} />
|
<SchedaGiocatore
|
||||||
|
key={g.id}
|
||||||
|
g={g}
|
||||||
|
profilo={profili[g.id]}
|
||||||
|
oggi={oggi}
|
||||||
|
indice={i}
|
||||||
|
aperta={schedaAperta === g.id}
|
||||||
|
onToggle={() => setSchedaAperta((v) => (v === g.id ? null : g.id))}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
);
|
||||||
</Section>
|
|
||||||
|
|
||||||
{disattivi.length > 0 ? (
|
const contenutoDisattivati = (
|
||||||
<Section titolo="Giocatori disattivati" indice={2}>
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{disattivi.map((g) => (
|
{disattivi.map((g) => (
|
||||||
<GiocatoreDisattivato key={g.id} g={g} />
|
<GiocatoreDisattivato key={g.id} g={g} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
);
|
||||||
) : null}
|
|
||||||
|
const contenutoNotifiche = notificheAttive ? (
|
||||||
|
<>
|
||||||
|
<StatTile
|
||||||
|
valore={`${attivi.filter((g) => notificheAttive.has(g.id)).length}/${attivi.length}`}
|
||||||
|
label="Notifiche attive"
|
||||||
|
/>
|
||||||
|
<div className="mt-3 space-y-2">
|
||||||
|
{attivi
|
||||||
|
.filter((g) => notificheAttive.has(g.id))
|
||||||
|
.map((g) => (
|
||||||
|
<div key={g.id} className="flex items-center gap-2 rounded-2xl bg-card p-3 shadow-card">
|
||||||
|
<Bell className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
|
||||||
|
<p className="truncate text-sm font-semibold leading-tight">{nomeCompleto(g)}</p>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<p className="rounded-2xl bg-card p-5 text-center text-sm text-muted-foreground shadow-card">
|
||||||
|
Caricamento…
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageHeader titolo="Dashboard" sottotitolo="Profili e tesseramento" />
|
||||||
|
|
||||||
|
<BarraSottosezioni
|
||||||
|
defaultId="squadra"
|
||||||
|
variante="sottolineatura"
|
||||||
|
riempiLarghezza
|
||||||
|
voci={[
|
||||||
|
{ id: "squadra", label: "Squadra", contenuto: contenutoSquadra },
|
||||||
|
{ id: "profili", label: "Profili", contenuto: contenutoProfili },
|
||||||
|
...(disattivi.length > 0
|
||||||
|
? [{ id: "disattivati", label: "Disattivati", contenuto: contenutoDisattivati }]
|
||||||
|
: []),
|
||||||
|
{ id: "notifiche", label: "Notifiche", contenuto: contenutoNotifiche },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { richiediAdmin } from "@/lib/auth-route.server";
|
||||||
|
import { idsConNotificheAttive } from "@/lib/notifiche-attive.server";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/api/public/notifiche-attive")({
|
||||||
|
server: {
|
||||||
|
handlers: {
|
||||||
|
GET: async ({ request }) => {
|
||||||
|
const negato = await richiediAdmin(request);
|
||||||
|
if (negato) return negato;
|
||||||
|
|
||||||
|
const { supabaseAdmin } = await import("@/integrations/supabase/client.server");
|
||||||
|
const { data, error } = await supabaseAdmin
|
||||||
|
.from("push_subscriptions")
|
||||||
|
.select("giocatore_id");
|
||||||
|
if (error) {
|
||||||
|
console.error("notifiche-attive", error);
|
||||||
|
return new Response("Errore lettura", { status: 500 });
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.json({ giocatoreIds: idsConNotificheAttive(data ?? []) });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
+92
-18
@@ -3,7 +3,7 @@ import { createFileRoute, Link } from "@tanstack/react-router";
|
|||||||
import { AlertTriangle, ChevronRight, RefreshCw } from "lucide-react";
|
import { AlertTriangle, ChevronRight, RefreshCw } from "lucide-react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { formatData, type RigaClassifica } from "@/lib/crapp-data";
|
import { formatData, type RigaClassifica } from "@/lib/crapp-data";
|
||||||
import { PageHeader } from "@/components/crapp/ui-bits";
|
import { PageHeader, TeamLogo } from "@/components/crapp/ui-bits";
|
||||||
import { BarraSottosezioni } from "@/components/crapp/BarraSottosezioni";
|
import { BarraSottosezioni } from "@/components/crapp/BarraSottosezioni";
|
||||||
import { useScoutMatches } from "@/lib/scout-store";
|
import { useScoutMatches } from "@/lib/scout-store";
|
||||||
import { useCsi } from "@/lib/csi";
|
import { useCsi } from "@/lib/csi";
|
||||||
@@ -12,6 +12,43 @@ import { useVotiMvp, vincitoriMvp } from "@/lib/mvp-voti";
|
|||||||
import { useEventi } from "@/lib/eventi";
|
import { useEventi } from "@/lib/eventi";
|
||||||
import { LogoSquadra } from "@/components/crapp/DettaglioCsi";
|
import { LogoSquadra } from "@/components/crapp/DettaglioCsi";
|
||||||
|
|
||||||
|
const LOGO_NOI = "/logo-nerorosso.svg";
|
||||||
|
const NOME_NOI = "CRAP Volley";
|
||||||
|
|
||||||
|
/** Logo CRAP o avversario; cerchio con iniziali se il CSI non ha l'immagine. */
|
||||||
|
function LogoPartita({
|
||||||
|
nostro,
|
||||||
|
logoAvversario,
|
||||||
|
avversario,
|
||||||
|
}: {
|
||||||
|
nostro: boolean;
|
||||||
|
logoAvversario: string;
|
||||||
|
avversario: string;
|
||||||
|
}) {
|
||||||
|
if (nostro) {
|
||||||
|
return (
|
||||||
|
<TeamLogo src={LOGO_NOI} className="h-8 w-8 rounded-lg shadow-none" />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (logoAvversario) {
|
||||||
|
return <LogoSquadra src={logoAvversario} alt={avversario} className="h-8 w-8" />;
|
||||||
|
}
|
||||||
|
const iniziali = avversario
|
||||||
|
.split(/\s+/)
|
||||||
|
.filter(Boolean)
|
||||||
|
.slice(0, 2)
|
||||||
|
.map((p) => p[0]?.toUpperCase() ?? "")
|
||||||
|
.join("");
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className="grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-secondary text-[10px] font-bold text-muted-foreground"
|
||||||
|
aria-hidden
|
||||||
|
>
|
||||||
|
{iniziali || "?"}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const TAB_CLASSIFICA = ["classifica", "storico"] as const;
|
const TAB_CLASSIFICA = ["classifica", "storico"] as const;
|
||||||
type TabClassifica = (typeof TAB_CLASSIFICA)[number];
|
type TabClassifica = (typeof TAB_CLASSIFICA)[number];
|
||||||
|
|
||||||
@@ -169,60 +206,96 @@ function Classifica() {
|
|||||||
{tuttiMatch.map((m) => {
|
{tuttiMatch.map((m) => {
|
||||||
const vinta = m.setNostri > m.setLoro;
|
const vinta = m.setNostri > m.setLoro;
|
||||||
const eventoId = eventoIdPerData.get(m.data);
|
const eventoId = eventoIdPerData.get(m.data);
|
||||||
|
const cliccabile = Boolean(eventoId) || !m.scout;
|
||||||
|
const casa = {
|
||||||
|
nome: m.casa ? NOME_NOI : m.avversario,
|
||||||
|
nostro: m.casa,
|
||||||
|
};
|
||||||
|
const trasferta = {
|
||||||
|
nome: m.casa ? m.avversario : NOME_NOI,
|
||||||
|
nostro: !m.casa,
|
||||||
|
};
|
||||||
|
// Badge e parziali in ordine casa–ospite; il colore resta sulla vittoria CRAP.
|
||||||
|
const setCasa = m.casa ? m.setNostri : m.setLoro;
|
||||||
|
const setOspite = m.casa ? m.setLoro : m.setNostri;
|
||||||
const contenuto = (
|
const contenuto = (
|
||||||
<>
|
<>
|
||||||
<div className="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3">
|
<div className="flex items-center gap-2">
|
||||||
|
<div className="min-w-0 flex-1 space-y-1.5">
|
||||||
<div className="flex min-w-0 items-center gap-2">
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
<LogoSquadra src={m.logoAvversario} alt={m.avversario} className="h-8 w-8" />
|
<LogoPartita
|
||||||
<div className="min-w-0">
|
nostro={casa.nostro}
|
||||||
<p className="truncate text-sm font-bold">
|
logoAvversario={m.logoAvversario}
|
||||||
{m.casa ? "CRAP Volley" : m.avversario} vs{" "}
|
avversario={m.avversario}
|
||||||
{m.casa ? m.avversario : "CRAP Volley"}
|
/>
|
||||||
</p>
|
<p className="truncate text-sm font-bold">{casa.nome}</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
|
<LogoPartita
|
||||||
|
nostro={trasferta.nostro}
|
||||||
|
logoAvversario={m.logoAvversario}
|
||||||
|
avversario={m.avversario}
|
||||||
|
/>
|
||||||
|
<p className="truncate text-sm font-bold">{trasferta.nome}</p>
|
||||||
|
</div>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{formatData(m.data)} · MVP {m.mvp || "da votare"}
|
{formatData(m.data)} · MVP {m.mvp || "da votare"}
|
||||||
{m.scout ? " · scoutata" : ""}
|
{m.scout ? " · scoutata" : ""}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-xl px-2.5 py-1 font-display text-lg",
|
"shrink-0 rounded-xl px-2.5 py-1 font-display text-xl",
|
||||||
vinta
|
vinta
|
||||||
? "bg-success text-success-foreground"
|
? "bg-success text-success-foreground"
|
||||||
: "bg-destructive text-destructive-foreground",
|
: "bg-destructive text-destructive-foreground",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{m.setNostri}-{m.setLoro}
|
{setCasa}-{setOspite}
|
||||||
</span>
|
</span>
|
||||||
|
{cliccabile ? (
|
||||||
|
<ChevronRight
|
||||||
|
className="h-5 w-5 shrink-0 text-muted-foreground"
|
||||||
|
aria-hidden
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-3 flex flex-wrap items-center gap-1.5">
|
<div className="mt-3 flex flex-wrap items-center gap-1.5">
|
||||||
{m.parziali.map((p, i) => (
|
{m.parziali.map((p, i) => {
|
||||||
|
const puntiCasa = m.casa ? p[0] : p[1];
|
||||||
|
const puntiOspite = m.casa ? p[1] : p[0];
|
||||||
|
const setVintoDaNoi = p[0] > p[1];
|
||||||
|
return (
|
||||||
<span
|
<span
|
||||||
key={i}
|
key={i}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-lg px-2 py-1 text-xs font-semibold tabular-nums",
|
"rounded-lg px-2 py-1 text-xs font-semibold tabular-nums",
|
||||||
p[0] > p[1] ? "bg-secondary" : "bg-muted text-muted-foreground",
|
setVintoDaNoi
|
||||||
|
? "bg-secondary"
|
||||||
|
: "bg-muted text-muted-foreground",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{p[0]}-{p[1]}
|
{puntiCasa}-{puntiOspite}
|
||||||
</span>
|
</span>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
{eventoId && !m.mvp ? (
|
{eventoId && !m.mvp ? (
|
||||||
<span className="ml-auto inline-flex items-center gap-0.5 text-xs font-bold uppercase text-accent">
|
<span className="ml-auto inline-flex items-center gap-0.5 text-xs font-bold uppercase text-accent">
|
||||||
Vota MVP <ChevronRight className="h-3.5 w-3.5" />
|
Vota MVP <ChevronRight className="h-3.5 w-3.5" aria-hidden />
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
const aria = `${casa.nome} vs ${trasferta.nome}: dettaglio partita`;
|
||||||
if (eventoId) {
|
if (eventoId) {
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
key={m.id}
|
key={m.id}
|
||||||
to="/partita/$id"
|
to="/partita/$id"
|
||||||
params={{ id: eventoId }}
|
params={{ id: eventoId }}
|
||||||
className="premi block rounded-3xl bg-card p-4 shadow-card active:scale-[0.99]"
|
aria-label={aria}
|
||||||
|
className="premi block rounded-3xl bg-card p-4 shadow-card ring-1 ring-transparent transition-[box-shadow,transform] active:scale-[0.99] hover:ring-accent/30"
|
||||||
>
|
>
|
||||||
{contenuto}
|
{contenuto}
|
||||||
</Link>
|
</Link>
|
||||||
@@ -240,7 +313,8 @@ function Classifica() {
|
|||||||
key={m.id}
|
key={m.id}
|
||||||
to="/partita-csi/$id"
|
to="/partita-csi/$id"
|
||||||
params={{ id: m.id }}
|
params={{ id: m.id }}
|
||||||
className="premi block rounded-3xl bg-card p-4 shadow-card active:scale-[0.99]"
|
aria-label={aria}
|
||||||
|
className="premi block rounded-3xl bg-card p-4 shadow-card ring-1 ring-transparent transition-[box-shadow,transform] active:scale-[0.99] hover:ring-accent/30"
|
||||||
>
|
>
|
||||||
{contenuto}
|
{contenuto}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/**
|
||||||
|
* Chi può leggere l'elenco dei giocatori con notifiche push attive:
|
||||||
|
* `bun test/integration/notifiche-attive-route.test.ts`.
|
||||||
|
*
|
||||||
|
* `/api/public/notifiche-attive` legge `push_subscriptions` con la service role e
|
||||||
|
* salta la RLS (come le route che mandano notifiche, DD-024): il permesso deve stare
|
||||||
|
* nella route. Serve un database vero per provare token di un giocatore normale e di
|
||||||
|
* un amministratore, quindi solo stack locale.
|
||||||
|
*/
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { statoLocale } from "../helpers/locale";
|
||||||
|
import { avviaServer, json } from "../helpers/server";
|
||||||
|
import { prova, riepilogo, salta } from "../helpers/prova";
|
||||||
|
|
||||||
|
const locale = statoLocale();
|
||||||
|
|
||||||
|
if (!locale) {
|
||||||
|
salta("notifiche attive: permessi route", "stack locale non attivo (npx supabase start)");
|
||||||
|
riepilogo("notifiche-attive-route");
|
||||||
|
} else {
|
||||||
|
const { url: SUPABASE, anon: ANON, servizio: SERVIZIO } = locale;
|
||||||
|
|
||||||
|
// Il server di sviluppo eredita queste: le route leggono i nomi senza prefisso.
|
||||||
|
process.env["SUPABASE_URL"] = SUPABASE;
|
||||||
|
process.env["SUPABASE_PUBLISHABLE_KEY"] = ANON;
|
||||||
|
process.env["SUPABASE_SERVICE_ROLE_KEY"] = SERVIZIO;
|
||||||
|
|
||||||
|
const PASSWORD = "prova-notifiche-123";
|
||||||
|
const idUtenti: string[] = [];
|
||||||
|
|
||||||
|
const authAdmin = { apikey: SERVIZIO, Authorization: `Bearer ${SERVIZIO}` };
|
||||||
|
|
||||||
|
async function creaUtente(email: string): Promise<string> {
|
||||||
|
const res = await fetch(`${SUPABASE}/auth/v1/admin/users`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { ...authAdmin, "content-type": "application/json" },
|
||||||
|
body: JSON.stringify({ email, password: PASSWORD, email_confirm: true }),
|
||||||
|
});
|
||||||
|
const corpo = (await res.json()) as { id?: string };
|
||||||
|
if (!corpo.id) throw new Error(`creazione utente fallita: ${JSON.stringify(corpo)}`);
|
||||||
|
idUtenti.push(corpo.id);
|
||||||
|
return corpo.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function accedi(email: string): Promise<string> {
|
||||||
|
const res = await fetch(`${SUPABASE}/auth/v1/token?grant_type=password`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { apikey: ANON, "content-type": "application/json" },
|
||||||
|
body: JSON.stringify({ email, password: PASSWORD }),
|
||||||
|
});
|
||||||
|
const corpo = (await res.json()) as { access_token?: string };
|
||||||
|
if (!corpo.access_token) throw new Error(`accesso fallito: ${JSON.stringify(corpo)}`);
|
||||||
|
return corpo.access_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
const emailGiocatore = `test-notifiche-giocatore-${Date.now()}@example.test`;
|
||||||
|
const emailAdmin = `test-notifiche-admin-${Date.now()}@example.test`;
|
||||||
|
await creaUtente(emailGiocatore);
|
||||||
|
const idAdmin = await creaUtente(emailAdmin);
|
||||||
|
await fetch(`${SUPABASE}/rest/v1/user_roles`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { ...authAdmin, "content-type": "application/json" },
|
||||||
|
body: JSON.stringify({ user_id: idAdmin, role: "admin" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const tokenGiocatore = await accedi(emailGiocatore);
|
||||||
|
const tokenAdmin = await accedi(emailAdmin);
|
||||||
|
|
||||||
|
const server = await avviaServer();
|
||||||
|
console.log(`notifiche-attive-route su ${server.baseUrl} (database ${SUPABASE})`);
|
||||||
|
|
||||||
|
const PERCORSO = "/api/public/notifiche-attive";
|
||||||
|
const chiama = (intestazioni: Record<string, string> = {}) =>
|
||||||
|
fetch(`${server.baseUrl}${PERCORSO}`, { headers: intestazioni });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await prova("senza token la route non risponde", async () => {
|
||||||
|
assert.equal((await chiama()).status, 401);
|
||||||
|
});
|
||||||
|
|
||||||
|
await prova("un giocatore autenticato non è admin", async () => {
|
||||||
|
const res = await chiama({ authorization: `Bearer ${tokenGiocatore}` });
|
||||||
|
assert.equal(res.status, 403);
|
||||||
|
});
|
||||||
|
|
||||||
|
await prova("un amministratore riceve l'elenco degli id", async () => {
|
||||||
|
const res = await chiama({ authorization: `Bearer ${tokenAdmin}` });
|
||||||
|
assert.equal(res.status, 200);
|
||||||
|
const corpo = (await json(res)) as { giocatoreIds: unknown };
|
||||||
|
assert.ok(Array.isArray(corpo.giocatoreIds), "giocatoreIds è un array");
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
server.stop();
|
||||||
|
for (const id of idUtenti) {
|
||||||
|
await fetch(`${SUPABASE}/rest/v1/user_roles?user_id=eq.${id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: authAdmin,
|
||||||
|
});
|
||||||
|
await fetch(`${SUPABASE}/auth/v1/admin/users/${id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: authAdmin,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
riepilogo("notifiche-attive-route");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Check della segnalazione errori verso l'editor Lovable: `bun test/unit/lovable-error-reporting.test.ts`.
|
|
||||||
* Fuori dal browser (nessun `window`) deve essere un no-op silenzioso; qui simuliamo
|
|
||||||
* anche un `window` minimale per verificare cosa viene inoltrato al hook di reporting.
|
|
||||||
*/
|
|
||||||
import assert from "node:assert/strict";
|
|
||||||
import { reportLovableError } from "@/lib/lovable-error-reporting";
|
|
||||||
|
|
||||||
// --- fuori dal browser: nessun window, nessun crash ---------------------------
|
|
||||||
assert.equal(typeof window, "undefined", "il test gira in ambiente server, senza DOM");
|
|
||||||
assert.doesNotThrow(() => reportLovableError(new Error("boom")));
|
|
||||||
|
|
||||||
// --- con un window simulato: inoltra al hook dell'editor ----------------------
|
|
||||||
type Riportato = { message: string; stack?: string; filename?: string };
|
|
||||||
let riportato: Riportato | undefined;
|
|
||||||
const finto = {
|
|
||||||
location: { pathname: "/rosa" },
|
|
||||||
__lovableReportRuntimeError: (payload: Riportato) => {
|
|
||||||
riportato = payload;
|
|
||||||
},
|
|
||||||
} as unknown as Window & typeof globalThis;
|
|
||||||
|
|
||||||
(globalThis as { window?: unknown }).window = finto;
|
|
||||||
try {
|
|
||||||
reportLovableError(new Error("qualcosa è andato storto"));
|
|
||||||
assert.ok(riportato, "il payload è stato inoltrato");
|
|
||||||
assert.equal(riportato!.message, "qualcosa è andato storto");
|
|
||||||
assert.equal(riportato!.filename, "/rosa");
|
|
||||||
assert.ok(riportato!.stack, "include lo stack per un Error");
|
|
||||||
|
|
||||||
// Una Response non ha un messaggio leggibile: si usa status + url.
|
|
||||||
riportato = undefined;
|
|
||||||
reportLovableError(new Response(null, { status: 404 }));
|
|
||||||
assert.equal(riportato!.message, "Response 404");
|
|
||||||
assert.equal(riportato!.stack, undefined, "una Response non ha stack");
|
|
||||||
|
|
||||||
// Un valore qualunque diventa la sua stringa.
|
|
||||||
riportato = undefined;
|
|
||||||
reportLovableError("motivo generico");
|
|
||||||
assert.equal(riportato!.message, "motivo generico");
|
|
||||||
} finally {
|
|
||||||
delete (globalThis as { window?: unknown }).window;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.equal(typeof window, "undefined", "il window simulato non è rimasto in giro");
|
|
||||||
|
|
||||||
console.log("lovable-error-reporting: ok");
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Check della deduplica per la sezione Notifiche in admin:
|
||||||
|
* `bun test/unit/notifiche-attive.test.ts`.
|
||||||
|
*/
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { idsConNotificheAttive } from "@/lib/notifiche-attive.server";
|
||||||
|
|
||||||
|
assert.deepEqual(idsConNotificheAttive([]), [], "nessuna riga -> nessun id");
|
||||||
|
|
||||||
|
assert.deepEqual(idsConNotificheAttive([{ giocatore_id: "g1" }]), ["g1"], "una riga -> un id");
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
idsConNotificheAttive([{ giocatore_id: "g1" }, { giocatore_id: "g1" }, { giocatore_id: "g2" }]),
|
||||||
|
["g1", "g2"],
|
||||||
|
"più dispositivi dello stesso giocatore contano una volta sola",
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
idsConNotificheAttive([{ giocatore_id: "g2" }, { giocatore_id: "g1" }]),
|
||||||
|
["g2", "g1"],
|
||||||
|
"ordine di prima comparsa, non alfabetico",
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log("notifiche-attive: ok");
|
||||||
+87
-9
@@ -1,15 +1,93 @@
|
|||||||
// @lovable.dev/vite-tanstack-config already includes the following — do NOT add them manually
|
import { defineConfig, loadEnv, mergeConfig } from "vite";
|
||||||
// or the app will break with duplicate plugins:
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
// - TanStack devtools (dev-only, first), tanstackStart, viteReact, tailwindcss, tsConfigPaths,
|
import tsConfigPaths from "vite-tsconfig-paths";
|
||||||
// nitro (build-only using cloudflare as a default target), VITE_* env injection, @ path alias,
|
import viteReact from "@vitejs/plugin-react";
|
||||||
// React/TanStack dedupe, error logger plugins, and sandbox detection (port/host/strictPort).
|
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
||||||
// You can pass additional config via defineConfig({ vite: { ... }, etc... }) if needed.
|
import { devtools } from "@tanstack/devtools-vite";
|
||||||
import { defineConfig } from "@lovable.dev/vite-tanstack-config";
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig(async ({ command, mode }) => {
|
||||||
tanstackStart: {
|
const isDevBuild = command === "build" && mode === "development";
|
||||||
|
|
||||||
|
const loadedEnv = loadEnv(mode, process.cwd(), "VITE_");
|
||||||
|
const envDefine: Record<string, string> = {};
|
||||||
|
for (const [key, value] of Object.entries(loadedEnv)) {
|
||||||
|
envDefine[`import.meta.env.${key}`] = JSON.stringify(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const plugins = [];
|
||||||
|
if (mode === "development") {
|
||||||
|
plugins.push(
|
||||||
|
devtools({
|
||||||
|
logging: false,
|
||||||
|
eventBusConfig: { enabled: false },
|
||||||
|
enhancedLogs: { enabled: false },
|
||||||
|
consolePiping: { enabled: false },
|
||||||
|
removeDevtoolsOnBuild: false,
|
||||||
|
injectSource: { enabled: true },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
plugins.push(tailwindcss());
|
||||||
|
plugins.push(tsConfigPaths({ projects: ["./tsconfig.json"] }));
|
||||||
|
plugins.push(
|
||||||
|
tanstackStart({
|
||||||
|
importProtection: {
|
||||||
|
behavior: "error",
|
||||||
|
client: { files: ["**/server/**"], specifiers: ["server-only"] },
|
||||||
|
},
|
||||||
// Redirect TanStack Start's bundled server entry to src/server.ts (our SSR error wrapper).
|
// Redirect TanStack Start's bundled server entry to src/server.ts (our SSR error wrapper).
|
||||||
// nitro/vite builds from this
|
// nitro/vite builds from this
|
||||||
server: { entry: "server" },
|
server: { entry: "server" },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (command === "build") {
|
||||||
|
const { nitro } = await import("nitro/vite");
|
||||||
|
plugins.push(nitro({ defaultPreset: "cloudflare-module" }));
|
||||||
|
}
|
||||||
|
plugins.push(viteReact());
|
||||||
|
|
||||||
|
let config = {
|
||||||
|
define: envDefine,
|
||||||
|
...(isDevBuild
|
||||||
|
? {
|
||||||
|
environments: {
|
||||||
|
client: { define: { "process.env.NODE_ENV": JSON.stringify("development") } },
|
||||||
|
},
|
||||||
|
esbuild: { keepNames: true },
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
css: { transformer: "lightningcss" as const },
|
||||||
|
resolve: {
|
||||||
|
alias: { "@": `${process.cwd()}/src` },
|
||||||
|
dedupe: [
|
||||||
|
"react",
|
||||||
|
"react-dom",
|
||||||
|
"react/jsx-runtime",
|
||||||
|
"react/jsx-dev-runtime",
|
||||||
|
"@tanstack/react-query",
|
||||||
|
"@tanstack/query-core",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
optimizeDeps: {
|
||||||
|
include: [
|
||||||
|
"react",
|
||||||
|
"react-dom",
|
||||||
|
"react-dom/client",
|
||||||
|
"react/jsx-runtime",
|
||||||
|
"react/jsx-dev-runtime",
|
||||||
|
],
|
||||||
|
ignoreOutdatedRequests: true,
|
||||||
|
},
|
||||||
|
plugins,
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mergeConfig(config, {
|
||||||
|
server: {
|
||||||
|
host: "::",
|
||||||
|
port: 8080,
|
||||||
|
watch: { awaitWriteFinish: { stabilityThreshold: 1000, pollInterval: 100 } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user