From 6d07135b97da2c3963e035a6cab3d890115526db Mon Sep 17 00:00:00 2001 From: frakarr Date: Thu, 11 Dec 2025 22:51:02 +0100 Subject: [PATCH] Update Settings.tsx --- pages/Settings.tsx | 611 +++++++++++++++++++++------------------------ 1 file changed, 286 insertions(+), 325 deletions(-) diff --git a/pages/Settings.tsx b/pages/Settings.tsx index a31c657..53c1231 100644 --- a/pages/Settings.tsx +++ b/pages/Settings.tsx @@ -48,7 +48,8 @@ export const SettingsPage: React.FC = () => { zipCode: '', notes: '', paypalClientId: '', - defaultMonthlyQuota: 100 + defaultMonthlyQuota: 100, + dueDay: 10 }); const [saving, setSaving] = useState(false); @@ -302,13 +303,13 @@ export const SettingsPage: React.FC = () => { // CRUD Handlers const openAddCondoModal = () => { setEditingCondo(null); - setCondoForm({ name: '', address: '', streetNumber: '', city: '', province: '', zipCode: '', notes: '', paypalClientId: '', defaultMonthlyQuota: 100 }); + setCondoForm({ name: '', address: '', streetNumber: '', city: '', province: '', zipCode: '', notes: '', paypalClientId: '', defaultMonthlyQuota: 100, dueDay: 10 }); setShowCondoModal(true); }; const openEditCondoModal = (c: Condo) => { setEditingCondo(c); - setCondoForm({ name: c.name, address: c.address || '', streetNumber: c.streetNumber || '', city: c.city || '', province: c.province || '', zipCode: c.zipCode || '', notes: c.notes || '', paypalClientId: c.paypalClientId || '', defaultMonthlyQuota: c.defaultMonthlyQuota }); + setCondoForm({ name: c.name, address: c.address || '', streetNumber: c.streetNumber || '', city: c.city || '', province: c.province || '', zipCode: c.zipCode || '', notes: c.notes || '', paypalClientId: c.paypalClientId || '', defaultMonthlyQuota: c.defaultMonthlyQuota, dueDay: c.dueDay || 10 }); setShowCondoModal(true); }; @@ -325,7 +326,8 @@ export const SettingsPage: React.FC = () => { zipCode: condoForm.zipCode, notes: condoForm.notes, paypalClientId: condoForm.paypalClientId, - defaultMonthlyQuota: condoForm.defaultMonthlyQuota + defaultMonthlyQuota: condoForm.defaultMonthlyQuota, + dueDay: condoForm.dueDay }; const savedCondo = await CondoService.saveCondo(payload); const list = await CondoService.getCondos(); @@ -693,7 +695,18 @@ export const SettingsPage: React.FC = () => {
setActiveCondo({ ...activeCondo, city: e.target.value })} className="w-full border p-2.5 rounded-lg text-slate-700" required/>
setActiveCondo({ ...activeCondo, province: e.target.value })} className="w-full border p-2.5 rounded-lg text-slate-700" required/>
{globalSettings?.features.payPal && (
Configurazione Pagamenti
setActiveCondo({...activeCondo, paypalClientId: e.target.value})} />

Necessario per abilitare i pagamenti online delle rate.

)} -
setActiveCondo({ ...activeCondo, defaultMonthlyQuota: parseFloat(e.target.value) })} className="w-full border p-2.5 rounded-lg text-slate-700" placeholder="Quota Default" required />
+ +
+
+ + setActiveCondo({ ...activeCondo, defaultMonthlyQuota: parseFloat(e.target.value) })} className="w-full border p-2.5 rounded-lg text-slate-700" placeholder="Quota Default" required /> +
+
+ + setActiveCondo({ ...activeCondo, dueDay: parseInt(e.target.value) })} className="w-full border p-2.5 rounded-lg text-slate-700" required /> +
+
+
{successMsg}
@@ -721,40 +734,38 @@ export const SettingsPage: React.FC = () => { {/* FAMILIES TAB */} {isPrivileged && activeTab === 'families' && ( -
- {!activeCondo ? (

Seleziona o crea un condominio per gestire le famiglie.

) : ( - <> -
Famiglie in: {activeCondo.name}
+
+

Elenco Famiglie

Condominio: {activeCondo?.name}

- - - {families.map(family => ( - - - - - - - - ))} - -
NomeDettagliEmailQuotaAzioni
{family.name}
Int: {family.unitNumber || '-'}{(family.stair || family.floor) && ({family.stair ? `Scala: ${family.stair} ` : ''} {family.floor ? `Piano: ${family.floor}` : ''})}
{family.contactEmail}{family.customMonthlyQuota ? (€ {family.customMonthlyQuota}) : (Default (€ {activeCondo.defaultMonthlyQuota}))}
+ + + + {families.map(f => ( + + ))} + {families.length === 0 && } + +
NominativoInternoEmailAzioni
{f.name}{f.unitNumber}{f.contactEmail}
Nessuna famiglia registrata.
- - )} -
+
)} - + {/* USERS TAB */} {isPrivileged && activeTab === 'users' && (
-
+

Utenti & Accessi

Gestione account di accesso

- - - {users.map(u => ())} - -
UtenteRuoloAzioni
{u.name}
{u.email}
{u.role}
+ + + + {users.map(u => { + const fam = families.find(f => f.id === u.familyId); + return ( + + ); + })} + +
EmailRuoloFamigliaAzioni
{u.email}{u.role}{fam ? `${fam.name} (${fam.unitNumber})` : '-'}
)} @@ -762,197 +773,71 @@ export const SettingsPage: React.FC = () => { {/* NOTICES TAB */} {isPrivileged && activeTab === 'notices' && (
-

Bacheca Condominiale

Pubblica avvisi visibili a tutti i condomini.

-
+

Bacheca Avvisi

+
{notices.map(notice => { - const isTargeted = notice.targetFamilyIds && notice.targetFamilyIds.length > 0; + const reads = noticeReadStats[notice.id] || []; + const targetCount = notice.targetFamilyIds?.length || 0; return ( -
-
-
-
{notice.type === 'warning' ? : notice.type === 'maintenance' ? : notice.type === 'event' ? : }
-

{notice.title}{isTargeted && ( Privato)}

{getCondoName(notice.condoId)} • {new Date(notice.date).toLocaleDateString()}

{notice.content}

{notice.link && Allegato}{isTargeted && (

Visibile a: {notice.targetFamilyIds!.length} famiglie

)}
-
-
-
-
-
- ); +
+
+
+

{notice.title}

+ {notice.active ? 'Attivo' : 'Archiviato'} + • {new Date(notice.date).toLocaleDateString()} +
+

{notice.content}

+
+ + Destinatari: {targetCount === 0 ? 'Tutti' : `${targetCount} Famiglie`} + + +
+
+
+ + + +
+
+ ); })} - {notices.length === 0 &&
Nessun avviso pubblicato.
} + {notices.length === 0 &&
Nessun avviso in bacheca.
}
)} {/* ALERTS TAB */} {isPrivileged && activeTab === 'alerts' && ( -
-
-

Avvisi Automatici

Configura email automatiche per scadenze.

-
- {alerts.map(alert => ( -
-

{alert.subject}

{alert.body}

-
Offset: {alert.daysOffset} giorni ({alert.offsetType})Ore: {alert.sendHour}:00{alert.active ? 'Attivo' : 'Inattivo'}
-
-
- ))} - {alerts.length === 0 &&
Nessun alert configurato.
} -
-
- )} - - {/* --- MODALS --- */} - - {/* Notice Modal */} - {showNoticeModal && ( -
-
-

{editingNotice ? 'Modifica Avviso' : 'Nuovo Avviso'}

-
-
- setNoticeForm({...noticeForm, title: e.target.value})} required /> - -
-
- -

Lasciare vuoto per usare il default del condominio (€ {activeCondo?.defaultMonthlyQuota})

- setFamilyForm({...familyForm, customMonthlyQuota: e.target.value})} className="w-full border rounded-lg p-2.5 text-slate-700" placeholder="Es. 120.00"/> -
-
- - -
- -
-
- )} - - {/* Alert Modal */} - {showAlertModal && ( -
-
-

{editingAlert ? 'Modifica Avviso' : 'Nuovo Avviso Automatico'}

-
- setAlertForm({...alertForm, subject: e.target.value})} required /> -