added cache system

This commit is contained in:
2026-02-12 22:22:53 +01:00
parent 991569d9eb
commit a7ef46640d
7 changed files with 120 additions and 229 deletions

View File

@@ -48,7 +48,7 @@ function populateTimeSelects() {
}
async function loadOffices() {
const response = await api.get('/api/offices');
const response = await api.getCached('/api/offices', 60);
if (response && response.ok) {
offices = await response.json();
renderOffices();
@@ -115,6 +115,7 @@ async function deleteOffice(officeId) {
const response = await api.delete(`/api/offices/${officeId}`);
if (response && response.ok) {
utils.showMessage('Ufficio eliminato', 'success');
api.invalidateCache('/api/offices'); // Clear cache
await loadOffices();
} else {
const error = await response.json();
@@ -177,6 +178,7 @@ async function handleOfficeSubmit(e) {
if (response && response.ok) {
closeModal();
utils.showMessage(officeId ? 'Ufficio aggiornato' : 'Ufficio creato', 'success');
api.invalidateCache('/api/offices'); // Clear cache
await loadOffices();
} else {
let errorMessage = 'Errore operazione';