piccoli fix
This commit is contained in:
@@ -234,36 +234,44 @@ async function handleClearPresence(date) {
|
||||
async function handleReleaseParking(assignmentId) {
|
||||
if (!confirm('Rilasciare il parcheggio per questa data?')) return;
|
||||
|
||||
const response = await api.post(`/api/parking/release-my-spot/${assignmentId}`);
|
||||
utils.showMessage('Rilascio in corso...', 'warning');
|
||||
const response = await api.post('/api/parking/reassign-spot', {
|
||||
assignment_id: assignmentId,
|
||||
new_user_id: null
|
||||
});
|
||||
|
||||
if (response && response.ok) {
|
||||
await loadParkingAssignments();
|
||||
utils.showMessage('Posto liberato con successo', 'success');
|
||||
await Promise.all([loadParkingAssignments(), loadDailyStatus()]);
|
||||
renderCalendar();
|
||||
ModalLogic.closeModal();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
alert(error.detail || 'Impossibile rilasciare il parcheggio');
|
||||
utils.showMessage(error.detail || 'Impossibile rilasciare il parcheggio', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReassignParking(assignmentId, newUserId) {
|
||||
// Basic validation handled by select; confirm
|
||||
if (!assignmentId || !newUserId) {
|
||||
alert('Seleziona un utente');
|
||||
utils.showMessage('Seleziona un utente', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
utils.showMessage('Riassegnazione in corso...', 'warning');
|
||||
const response = await api.post('/api/parking/reassign-spot', {
|
||||
assignment_id: assignmentId,
|
||||
new_user_id: newUserId
|
||||
});
|
||||
|
||||
if (response && response.ok) {
|
||||
await loadParkingAssignments();
|
||||
utils.showMessage('Posto riassegnato con successo', 'success');
|
||||
await Promise.all([loadParkingAssignments(), loadDailyStatus()]);
|
||||
renderCalendar();
|
||||
ModalLogic.closeModal();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
alert(error.detail || 'Impossibile riassegnare il parcheggio');
|
||||
utils.showMessage(error.detail || 'Impossibile riassegnare il parcheggio', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,25 +584,14 @@ function renderParkingStatus(assignments) {
|
||||
el.style.cursor = 'pointer';
|
||||
el.addEventListener('mouseenter', () => el.style.boxShadow = '0 4px 6px rgba(0,0,0,0.1)');
|
||||
el.addEventListener('mouseleave', () => el.style.boxShadow = 'none');
|
||||
el.title = "Clicca per liberare questo posto";
|
||||
el.addEventListener('click', async () => {
|
||||
if (!confirm(`Vuoi liberare il posto ${spotName} occupato da ${statusText}?`)) return;
|
||||
|
||||
utils.showMessage('Rilascio in corso...', 'warning');
|
||||
const response = await api.post('/api/parking/reassign-spot', {
|
||||
assignment_id: a.id,
|
||||
new_user_id: null
|
||||
el.title = "Clicca per gestire questo posto";
|
||||
el.addEventListener('click', () => {
|
||||
ModalLogic.openModal({
|
||||
dateStr: a.date,
|
||||
parking: a,
|
||||
userName: a.user_name,
|
||||
isParkingOnly: true
|
||||
});
|
||||
|
||||
if (response && response.ok) {
|
||||
utils.showMessage('Posto liberato con successo', 'success');
|
||||
loadDailyStatus();
|
||||
loadParkingAssignments();
|
||||
renderCalendar();
|
||||
} else {
|
||||
const err = await response.json();
|
||||
utils.showMessage(err.detail || 'Impossibile liberare il posto', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user