added cache system
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user