Update Settings.tsx
This commit is contained in:
@@ -491,7 +491,7 @@ export const SettingsPage: React.FC = () => {
|
|||||||
const updated = { ...notice, active: !notice.active };
|
const updated = { ...notice, active: !notice.active };
|
||||||
await CondoService.saveNotice(updated);
|
await CondoService.saveNotice(updated);
|
||||||
setNotices(notices.map(n => n.id === notice.id ? updated : n));
|
setNotices(notices.map(n => n.id === notice.id ? updated : n));
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -698,62 +698,68 @@ export const SettingsPage: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* STORAGE CONFIG TAB */}
|
{/* STORAGE CONFIG TAB */}
|
||||||
{isPrivileged && activeTab === 'storage' && globalSettings?.storageConfig && (
|
{isPrivileged && activeTab === 'storage' && (
|
||||||
<div className="animate-fade-in bg-white rounded-xl shadow-sm border border-slate-200 p-6 max-w-2xl">
|
<div className="animate-fade-in bg-white rounded-xl shadow-sm border border-slate-200 p-6 max-w-2xl">
|
||||||
<h3 className="text-lg font-bold text-slate-800 mb-4 flex items-center gap-2"><Cloud className="w-5 h-5 text-blue-600" /> Configurazione Storage</h3>
|
<h3 className="text-lg font-bold text-slate-800 mb-4 flex items-center gap-2"><Cloud className="w-5 h-5 text-blue-600" /> Configurazione Storage</h3>
|
||||||
<p className="text-sm text-slate-500 mb-6">Scegli dove salvare i documenti caricati.</p>
|
<p className="text-sm text-slate-500 mb-6">Scegli dove salvare i documenti caricati.</p>
|
||||||
|
|
||||||
<form onSubmit={handleStorageSubmit} className="space-y-6">
|
<form onSubmit={handleStorageSubmit} className="space-y-6">
|
||||||
<div>
|
{globalSettings?.storageConfig ? (
|
||||||
<label className="text-sm font-bold text-slate-700 mb-2 block">Provider Attivo</label>
|
<>
|
||||||
<select
|
<div>
|
||||||
className="w-full border p-2.5 rounded-lg bg-slate-50 font-medium text-slate-700"
|
<label className="text-sm font-bold text-slate-700 mb-2 block">Provider Attivo</label>
|
||||||
value={globalSettings.storageConfig.provider}
|
<select
|
||||||
onChange={e => setGlobalSettings({
|
className="w-full border p-2.5 rounded-lg bg-slate-50 font-medium text-slate-700"
|
||||||
...globalSettings,
|
value={globalSettings.storageConfig.provider}
|
||||||
storageConfig: { ...globalSettings.storageConfig!, provider: e.target.value as any }
|
onChange={e => setGlobalSettings({
|
||||||
})}
|
...globalSettings,
|
||||||
>
|
storageConfig: { ...globalSettings.storageConfig!, provider: e.target.value as any }
|
||||||
<option value="local_db">Database Locale (Solo Demo)</option>
|
})}
|
||||||
<option value="s3">AWS S3 / Compatible</option>
|
>
|
||||||
<option value="google_drive">Google Drive</option>
|
<option value="local_db">Database Locale (Solo Demo)</option>
|
||||||
<option value="dropbox">Dropbox</option>
|
<option value="s3">AWS S3 / Compatible</option>
|
||||||
<option value="onedrive">OneDrive</option>
|
<option value="google_drive">Google Drive</option>
|
||||||
</select>
|
<option value="dropbox">Dropbox</option>
|
||||||
</div>
|
<option value="onedrive">OneDrive</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
{globalSettings.storageConfig.provider === 'local_db' && (
|
{globalSettings.storageConfig.provider === 'local_db' && (
|
||||||
<div className="bg-amber-50 text-amber-800 p-4 rounded-lg text-sm border border-amber-200">
|
<div className="bg-amber-50 text-amber-800 p-4 rounded-lg text-sm border border-amber-200">
|
||||||
<p className="font-bold">Modalità Demo Attiva</p>
|
<p className="font-bold">Modalità Demo Attiva</p>
|
||||||
<p>I file vengono salvati direttamente nel database (Base64). Non raccomandato per produzione o file grandi.</p>
|
<p>I file vengono salvati direttamente nel database (Base64). Non raccomandato per produzione o file grandi.</p>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{globalSettings.storageConfig.provider === 's3' && (
|
||||||
|
<div className="space-y-3 border-l-4 border-blue-500 pl-4">
|
||||||
|
<h4 className="font-bold text-sm text-slate-700">Configurazione S3</h4>
|
||||||
|
<input placeholder="Bucket Name" className="w-full border p-2 rounded" value={globalSettings.storageConfig.bucket || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, bucket: e.target.value}})}/>
|
||||||
|
<input placeholder="Region (es. eu-central-1)" className="w-full border p-2 rounded" value={globalSettings.storageConfig.region || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, region: e.target.value}})}/>
|
||||||
|
<input placeholder="Access Key ID" className="w-full border p-2 rounded" value={globalSettings.storageConfig.apiKey || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, apiKey: e.target.value}})}/>
|
||||||
|
<input type="password" placeholder="Secret Access Key" className="w-full border p-2 rounded" value={globalSettings.storageConfig.apiSecret || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, apiSecret: e.target.value}})}/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(globalSettings.storageConfig.provider === 'google_drive' || globalSettings.storageConfig.provider === 'dropbox' || globalSettings.storageConfig.provider === 'onedrive') && (
|
||||||
|
<div className="space-y-3 border-l-4 border-purple-500 pl-4">
|
||||||
|
<h4 className="font-bold text-sm text-slate-700">Autenticazione API</h4>
|
||||||
|
<p className="text-xs text-slate-500">Inserisci le credenziali dell'applicazione sviluppatore.</p>
|
||||||
|
<input placeholder="Client ID / App Key" className="w-full border p-2 rounded" value={globalSettings.storageConfig.apiKey || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, apiKey: e.target.value}})}/>
|
||||||
|
<input type="password" placeholder="Client Secret / App Secret" className="w-full border p-2 rounded" value={globalSettings.storageConfig.apiSecret || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, apiSecret: e.target.value}})}/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="pt-2 flex justify-between items-center">
|
||||||
|
<span className="text-green-600 font-medium">{successMsg}</span>
|
||||||
|
<button type="submit" disabled={saving} className="bg-blue-600 text-white px-6 py-2.5 rounded-lg font-medium hover:bg-blue-700 flex gap-2">
|
||||||
|
<Save className="w-4 h-4" /> Salva Impostazioni
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className="text-center p-4 text-slate-500">Inizializzazione configurazione storage...</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{globalSettings.storageConfig.provider === 's3' && (
|
|
||||||
<div className="space-y-3 border-l-4 border-blue-500 pl-4">
|
|
||||||
<h4 className="font-bold text-sm text-slate-700">Configurazione S3</h4>
|
|
||||||
<input placeholder="Bucket Name" className="w-full border p-2 rounded" value={globalSettings.storageConfig.bucket || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, bucket: e.target.value}})}/>
|
|
||||||
<input placeholder="Region (es. eu-central-1)" className="w-full border p-2 rounded" value={globalSettings.storageConfig.region || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, region: e.target.value}})}/>
|
|
||||||
<input placeholder="Access Key ID" className="w-full border p-2 rounded" value={globalSettings.storageConfig.apiKey || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, apiKey: e.target.value}})}/>
|
|
||||||
<input type="password" placeholder="Secret Access Key" className="w-full border p-2 rounded" value={globalSettings.storageConfig.apiSecret || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, apiSecret: e.target.value}})}/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(globalSettings.storageConfig.provider === 'google_drive' || globalSettings.storageConfig.provider === 'dropbox' || globalSettings.storageConfig.provider === 'onedrive') && (
|
|
||||||
<div className="space-y-3 border-l-4 border-purple-500 pl-4">
|
|
||||||
<h4 className="font-bold text-sm text-slate-700">Autenticazione API</h4>
|
|
||||||
<p className="text-xs text-slate-500">Inserisci le credenziali dell'applicazione sviluppatore.</p>
|
|
||||||
<input placeholder="Client ID / App Key" className="w-full border p-2 rounded" value={globalSettings.storageConfig.apiKey || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, apiKey: e.target.value}})}/>
|
|
||||||
<input type="password" placeholder="Client Secret / App Secret" className="w-full border p-2 rounded" value={globalSettings.storageConfig.apiSecret || ''} onChange={e => setGlobalSettings({...globalSettings, storageConfig: {...globalSettings.storageConfig!, apiSecret: e.target.value}})}/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="pt-2 flex justify-between items-center">
|
|
||||||
<span className="text-green-600 font-medium">{successMsg}</span>
|
|
||||||
<button type="submit" disabled={saving} className="bg-blue-600 text-white px-6 py-2.5 rounded-lg font-medium hover:bg-blue-700 flex gap-2">
|
|
||||||
<Save className="w-4 h-4" /> Salva Impostazioni
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user