diff --git a/.dockerignore b/.dockerignore index 10c5075..b3e90c2 100644 Binary files a/.dockerignore and b/.dockerignore differ diff --git a/.toignore b/.toignore deleted file mode 100644 index 79128ec..0000000 --- a/.toignore +++ /dev/null @@ -1 +0,0 @@ -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 diff --git a/Dockerfile b/Dockerfile index 67ce602..e69de29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +0,0 @@ -# Stage 1: Build del frontend -FROM node:20-alpine as build -WORKDIR /app -COPY package*.json ./ -RUN npm install -COPY . . -RUN npm run build - -# Stage 2: Serve con Nginx -FROM nginx:alpine -COPY --from=build /app/dist /usr/share/nginx/html -COPY nginx.conf /etc/nginx/conf.d/default.conf -EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] - diff --git a/nginx.conf b/nginx.conf index d620f7d..97684f0 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,22 +1 @@ -server { - listen 80; - - # Serve i file statici del frontend - location / { - root /usr/share/nginx/html; - index index.html index.htm; - # Fondamentale per il routing client-side di React (SPA) - try_files $uri $uri/ /index.html; - } - - # Proxy verso il backend - location /api { - # 'backend' è il nome del servizio definito nel docker-compose.yml - proxy_pass http://backend:3001; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - } -} +���z \ No newline at end of file diff --git a/pages/Settings.tsx b/pages/Settings.tsx index 94390b8..ffad62b 100644 --- a/pages/Settings.tsx +++ b/pages/Settings.tsx @@ -224,20 +224,30 @@ export const SettingsPage: React.FC = () => { const handleCondoSubmit = async (e: React.FormEvent) => { e.preventDefault(); try { + // FIX: Do not generate ID for new condo, let backend/service handle it (POST vs PUT check) const payload: Condo = { - id: editingCondo ? editingCondo.id : crypto.randomUUID(), + id: editingCondo ? editingCondo.id : '', name: condoForm.name, address: condoForm.address, defaultMonthlyQuota: condoForm.defaultMonthlyQuota }; - await CondoService.saveCondo(payload); + const savedCondo = await CondoService.saveCondo(payload); const list = await CondoService.getCondos(); setCondos(list); - if (activeCondo?.id === payload.id) setActiveCondo(payload); + + if (activeCondo?.id === savedCondo.id) { + setActiveCondo(savedCondo); + } + + // Auto-select if it's the first one or none selected + if (!activeCondo && list.length === 1) { + CondoService.setActiveCondo(savedCondo.id); + } + setShowCondoModal(false); window.dispatchEvent(new Event('condo-updated')); - } catch (e) { console.error(e); } + } catch (e) { console.error(e); alert("Errore nel salvataggio del condominio"); } }; const handleDeleteCondo = async (id: string) => { @@ -300,7 +310,10 @@ export const SettingsPage: React.FC = () => { setFamilies([...families, newFamily]); } setShowFamilyModal(false); - } catch (e) { console.error(e); } + } catch (e: any) { + console.error(e); + alert(`Errore: ${e.message || "Impossibile salvare la famiglia"}`); + } }; // --- User Handlers --- @@ -359,7 +372,7 @@ export const SettingsPage: React.FC = () => { ...noticeForm, date: editingNotice ? editingNotice.date : new Date().toISOString() }; - const saved = await CondoService.saveNotice(payload); + await CondoService.saveNotice(payload); setNotices(await CondoService.getNotices()); setShowNoticeModal(false); } catch (e) { console.error(e); } @@ -383,7 +396,7 @@ export const SettingsPage: React.FC = () => { setShowReadDetailsModal(true); }; - // --- Alert Handlers (Placeholder for brevity, logic same as before) --- + // --- Alert Handlers --- const openAddAlertModal = () => { setEditingAlert(null); setAlertForm({ subject: '', body: '', daysOffset: 1, offsetType: 'before_next_month', sendHour: 9, active: true }); setShowAlertModal(true); }; const openEditAlertModal = (alert: AlertDefinition) => { setEditingAlert(alert); setAlertForm(alert); setShowAlertModal(true); }; const handleAlertSubmit = async (e: React.FormEvent) => { @@ -463,7 +476,7 @@ export const SettingsPage: React.FC = () => { {isAdmin && activeTab === 'general' && (
| Nome | Interno | Quota | Azioni | |
|---|---|---|---|---|
| {family.name} | -{family.unitNumber} | -{family.contactEmail} | -- {family.customMonthlyQuota ? ( - € {family.customMonthlyQuota} - ) : ( - Default (€ {activeCondo?.defaultMonthlyQuota}) - )} - | -- |
Seleziona o crea un condominio per gestire le famiglie.
+| Nome | Interno | Quota | Azioni | |
|---|---|---|---|---|
| {family.name} | +{family.unitNumber} | +{family.contactEmail} | ++ {family.customMonthlyQuota ? ( + € {family.customMonthlyQuota} + ) : ( + Default (€ {activeCondo.defaultMonthlyQuota}) + )} + | ++ |