From 0dfda3a33888913003b715c930e7dc02feb40ef0 Mon Sep 17 00:00:00 2001 From: Carmine Savino Date: Tue, 20 Oct 2026 18:40:59 +0200 Subject: [PATCH] Refactor PVC models and update tests - Updated the PVC models in the database and adjusted the tests accordingly to reflect the new model counts and codes. - Removed deprecated models from the JSON data for PVC systems. - Added new GLB models for "scorrevole_sf_3_ante" and "scorrevole_sf_4_ante". - Enhanced the development scripts to streamline the build process for both frontends. - Updated documentation to reflect changes in the development environment and deployment process. - Improved the styling of texture radio options for better visibility. - Fixed URL handling in the configurator to ensure proper routing and API calls. --- .env | 5 +- .env.production.example | 7 +- .gitignore | 6 +- CLAUDE.md | 10 +- backoffice/.gitignore | 2 + backoffice/README.md | 36 ++-- backoffice/cliente/dist/index.html | 14 -- backoffice/cliente/src/App.vue | 7 +- backoffice/cliente/src/api.js | 3 +- backoffice/cliente/vite.config.js | 10 +- backoffice/config/preventivi.php | 10 +- ...0_20_130000_aggiorna_scorrevoli_sf_pvc.php | 86 ++++++++ .../seeders/data/configuratore_pvc.php | 2 - .../data/configuratore_pvc_catalogo.php | 4 +- .../database/seeders/data/modelli_pvc.php | 42 +--- backoffice/routes/web.php | 19 ++ .../tests/Feature/CatalogoAdminTest.php | 9 +- backoffice/tests/Feature/CatalogoApiTest.php | 8 +- .../tests/Feature/ImportazioneListiniTest.php | 2 +- build.sh | 16 +- dev.sh | 21 +- docs/AVVIO_LOCALE.md | 95 +++----- docs/ORIGINE_LISTINI_PVC.md | 2 - docs/PREVENTIVI_BACKOFFICE.md | 203 ++++++------------ src/assets/data/sistemi/pvc/modelli.json | 32 --- .../models/pvc/scorrevole_sf_3_ante.glb | Bin 0 -> 5120524 bytes .../models/pvc/scorrevole_sf_4_ante.glb | Bin 0 -> 5228756 bytes src/assets/style.css | 6 + src/index.html | 5 + src/js/api_base.js | 8 +- src/js/menu_builder.js | 15 ++ src/js/starter.js | 9 +- vite.config.js | 11 +- 33 files changed, 339 insertions(+), 366 deletions(-) delete mode 100644 backoffice/cliente/dist/index.html create mode 100644 backoffice/database/migrations/2026_10_20_130000_aggiorna_scorrevoli_sf_pvc.php create mode 100644 src/assets/models/pvc/scorrevole_sf_3_ante.glb create mode 100644 src/assets/models/pvc/scorrevole_sf_4_ante.glb diff --git a/.env b/.env index 4e3e163..1ddf6ff 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ -# Ambiente di sviluppo locale (pnpm dev). Usato solo dal browser (nessun segreto). -VITE_PREVENTIVI_API_BASE=http://localhost:8000/api +# Il configuratore è servito dal backend Laravel (/configuratore/) e usa l'API sulla stessa origine: +# non serve configurare nulla. Solo per puntare a un'API su un altro dominio: +# VITE_PREVENTIVI_API_BASE=https://altro-dominio.example/api diff --git a/.env.production.example b/.env.production.example index 2dd5887..23a087d 100644 --- a/.env.production.example +++ b/.env.production.example @@ -1,4 +1,3 @@ -# Copia questo file in .env.production e imposta l'URL reale dell'API Laravel prima del deploy -# (pnpm build usa .env.production quando presente). .env.production non è tracciato in git: -# va creato una volta per ambiente e non deve mai contenere un dominio "indovinato". -VITE_PREVENTIVI_API_BASE=https://preventivi.kreiosinfissi.it/api +# Opzionale: il configuratore usa di default l'API sulla stessa origine da cui è servito +# (/configuratore/ sul backend Laravel). Impostare solo per un'API su un dominio diverso. +# VITE_PREVENTIVI_API_BASE=https://preventivi.kreiosinfissi.it/api diff --git a/.gitignore b/.gitignore index e25a23a..88a5813 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ /.venv/ /kreios/ /dist/ -/backoffice/cliente/dist/ +/backoffice/public/configuratore/ +/backoffice/public/preventivo/ /node_modules/ kreios.zip .env.production Thumbs.db -/reference/icone_profili_extra \ No newline at end of file +/reference/icone_profili_extra +/reference/_* \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 6004a17..5172a15 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,11 +16,15 @@ also present). ```bash pnpm install # install deps -pnpm dev # vite dev server on 0.0.0.0:5173 -pnpm build # production build -> dist/ (root is src/, see vite.config.js) -pnpm preview # preview the production build +./dev.sh # single server: Laravel on :8000 + both frontends in `vite build --watch` +./build.sh # build configuratore + app cliente into backoffice/public +pnpm build # configuratore only -> backoffice/public/configuratore (root is src/) ``` +Everything is served by Laravel on one origin: configuratore at `/configuratore/?sistema=…&type=…`, quote +app (`backoffice/cliente`, Vue) at `/preventivo/`, API at `/api`, admin at `/admin`. The `index.html` of each +frontend is served by routes in `backoffice/routes/web.php`; there is no HMR, reload after the rebuild. + There is no test suite (`pnpm test` is a stub that exits with an error) and no linter configured. ### Regenerating PVC price lists diff --git a/backoffice/.gitignore b/backoffice/.gitignore index 649c292..164a66c 100644 --- a/backoffice/.gitignore +++ b/backoffice/.gitignore @@ -15,6 +15,8 @@ /auth.json node_modules /public/build +/public/configuratore +/public/preventivo /public/fonts-manifest.dev.json /public/hot /public/storage diff --git a/backoffice/README.md b/backoffice/README.md index 28d64b0..08e53f7 100644 --- a/backoffice/README.md +++ b/backoffice/README.md @@ -18,7 +18,7 @@ riassuntivo e invia le email a cliente e amministratore. 2. `starter.js` invia `POST /api/carrello/aggiungi` (con `sistema`, `type`, dimensioni, prezzo, payload, screenshot PNG). Il backend crea/aggiorna un `preventivo` (stato `bozza`) identificato da un `token` salvato in `localStorage`. -3. Il pulsante "Vai al preventivo" apre l'app cliente passando il token: `…/?token=XXX`. +3. Il pulsante "Vai al preventivo" apre l'app cliente passando il token: `/preventivo/?token=XXX`. 4. L'app cliente mostra il carrello, l'utente compila i dati e conferma → `POST /api/carrello/{token}/conferma`. 5. Il backend crea il `cliente`, imposta lo stato a `inviato`, genera il PDF e invia le email (cliente con PDF allegato + notifica admin). Il preventivo è visibile nel backoffice. @@ -33,20 +33,14 @@ php artisan migrate --seed # crea le tabelle + utente admin php artisan storage:link php artisan serve --port=8000 # API + admin su http://localhost:8000 -# 2. App cliente (cartella cliente/) -cd cliente -pnpm install -pnpm dev # http://localhost:5199 - -# 3. Configuratore (root del repo) +# 2. Frontend: configuratore + app cliente, compilati in public/ (dalla root del repo) cd .. -pnpm dev # http://localhost:5173 +./build.sh # -> public/configuratore e public/preventivo ``` -Le tre porte (8000 / 5199 / 5173) sono fisse (`strictPort: true` nei rispettivi `vite.config.js`): se una è -già occupata l'avvio fallisce con un errore esplicito invece di spostarsi silenziosamente su un'altra porta -— evita che il configuratore e l'app cliente finiscano per caso sulla stessa porta (successo in passato, -dato che entrambi avevano `5174` come default). +Configuratore e app cliente sono serviti da questo backend: +e . In sviluppo `./dev.sh` (root) avvia Laravel e ricompila i frontend +a ogni modifica. Dettagli in `../docs/PREVENTIVI_BACKOFFICE.md`. ### Credenziali admin (seed di default) - URL: @@ -62,19 +56,13 @@ In produzione configurare SMTP nel `.env`. |---|---| | `DB_*` | MySQL: `127.0.0.1`, `root`, no password, `kreios_preventivi` | | `ADMIN_NOTIFY_EMAIL` | Email che riceve la notifica di nuovo preventivo | -| `APP_FRONTEND_CLIENTE_URL` | URL dell'app cliente (per i link) | -| `CORS_ALLOWED_ORIGINS` | Origini autorizzate all'API (default `*` in dev) | +| `APP_FRONTEND_CLIENTE_URL` | URL dell'app cliente, solo se non servita da qui (default `APP_URL/preventivo`) | +| `CORS_ALLOWED_ORIGINS` | Origini esterne autorizzate all'API (default `*`; i frontend serviti da qui non ne hanno bisogno) | -### Configuratore (`../src/js/starter.js`) -`PREVENTIVI_API_BASE` è l'unico indirizzo che il configuratore deve conoscere a priori (default -`http://localhost:8000/api`, sovrascrivibile con `window.PREVENTIVI_API_BASE` prima del bundle). L'URL -dell'app cliente **non è hardcoded**: all'avvio il configuratore chiama `GET /api/config` e usa il -`frontend_cliente_url` restituito da Laravel (letto da `APP_FRONTEND_CLIENTE_URL` nel `.env`) — così non c'è -da tenere sincronizzati due URL se la porta Vite dell'app cliente cambia (es. per conflitto con altre porte -occupate). `window.APP_CLIENTE_URL` resta come fallback locale se il backend non è raggiungibile. - -### App cliente (`cliente/.env`) -`VITE_API_BASE` — URL base dell'API Laravel (default `http://localhost:8000/api`). +### Frontend +Configuratore e app cliente chiamano l'API sulla stessa origine (`${location.origin}/api`): nessuna +variabile da impostare. `VITE_PREVENTIVI_API_BASE` (root) / `VITE_API_BASE` (`cliente/`) servono solo per +un'API su un altro dominio. Il link "Vai al preventivo" usa `frontend_cliente_url` da `GET /api/config`. ## Modello dati diff --git a/backoffice/cliente/dist/index.html b/backoffice/cliente/dist/index.html deleted file mode 100644 index 9a352e7..0000000 --- a/backoffice/cliente/dist/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - Il tuo preventivo · Krèios - - - - -
- - diff --git a/backoffice/cliente/src/App.vue b/backoffice/cliente/src/App.vue index b29338d..eff9316 100644 --- a/backoffice/cliente/src/App.vue +++ b/backoffice/cliente/src/App.vue @@ -2,6 +2,9 @@ import { ref, reactive, computed, onMounted } from 'vue' import { api, resolveToken, resolveReturnUrl, resolveClienteToken, clearToken, formatEuro } from './api.js' +// Servita sotto /preventivo/: i file di public/ vanno risolti rispetto alla base della build. +const logoUrl = `${import.meta.env.BASE_URL}kreios-logo.jpg` + const step = ref('cart') // cart | checkout | done const loading = ref(true) const submitting = ref(false) @@ -158,7 +161,7 @@ onMounted(loadCarrello)