mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-03 20:12:59 +00:00
test ad
This commit is contained in:
+37
-29
@@ -4627,22 +4627,26 @@ async function deleteReservation(id) {
|
|||||||
if (!confirm('Opravdu chcete smazat tuto rezervaci?')) {
|
if (!confirm('Opravdu chcete smazat tuto rezervaci?')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/delete-reservation`, {
|
const token = localStorage.getItem('token');
|
||||||
method: 'POST',
|
if (!token) {
|
||||||
headers: {
|
window.location.href = '/login.html';
|
||||||
'Content-Type': 'application/json',
|
return;
|
||||||
},
|
|
||||||
body: JSON.stringify({ id: id })
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(result.error || 'Nepodařilo se smazat rezervaci');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`/api/reservations/${id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${token}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Nepodařilo se smazat rezervaci');
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the reservation from the local array and update the display
|
// Remove the reservation from the local array and update the display
|
||||||
window.allReservations = window.allReservations.filter(r => r.id !== id);
|
window.allReservations = window.allReservations.filter(r => r.id !== id);
|
||||||
updateVehicleFilter(window.allReservations);
|
updateVehicleFilter(window.allReservations);
|
||||||
@@ -4700,29 +4704,32 @@ async function saveReservation(event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ISO date strings
|
|
||||||
const start = new Date(`${startDate}T${startTime}`).toISOString();
|
|
||||||
const end = new Date(`${endDate}T${endTime}`).toISOString();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/update-reservation', {
|
const token = localStorage.getItem('token');
|
||||||
method: 'POST',
|
if (!token) {
|
||||||
|
window.location.href = '/login.html';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`/api/reservations/${id}`, {
|
||||||
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Authorization': `Bearer ${token}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
id,
|
|
||||||
driverName,
|
driverName,
|
||||||
vehicle,
|
vehicle,
|
||||||
start,
|
startDate,
|
||||||
end,
|
startTime,
|
||||||
|
endDate,
|
||||||
|
endTime,
|
||||||
purpose
|
purpose
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
const result = await response.json();
|
||||||
throw new Error(result.error || 'Nepodařilo se uložit změny');
|
throw new Error(result.error || 'Nepodařilo se uložit změny');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4733,8 +4740,10 @@ async function saveReservation(event) {
|
|||||||
...window.allReservations[index],
|
...window.allReservations[index],
|
||||||
driverName,
|
driverName,
|
||||||
vehicle,
|
vehicle,
|
||||||
start,
|
startDate,
|
||||||
end,
|
startTime,
|
||||||
|
endDate,
|
||||||
|
endTime,
|
||||||
purpose
|
purpose
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4792,7 +4801,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
|
|
||||||
// Load reservations when page loads
|
// Load reservations when page loads
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
// ...existing code...
|
|
||||||
loadReservations();
|
loadReservations();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+7
-33
@@ -1467,18 +1467,7 @@
|
|||||||
eventDidMount: function(info) {
|
eventDidMount: function(info) {
|
||||||
const vehicle = info.event.extendedProps.vehicle;
|
const vehicle = info.event.extendedProps.vehicle;
|
||||||
const vehicleClass = 'event-' + vehicle.toLowerCase().replace(/\s+/g, '-');
|
const vehicleClass = 'event-' + vehicle.toLowerCase().replace(/\s+/g, '-');
|
||||||
|
|
||||||
// Apply vehicle-specific styling
|
|
||||||
info.el.classList.add(vehicleClass);
|
info.el.classList.add(vehicleClass);
|
||||||
|
|
||||||
// Apply initial filtering
|
|
||||||
if (selectedVehicle !== 'all' && vehicle !== selectedVehicle) {
|
|
||||||
info.el.style.display = 'none';
|
|
||||||
info.el.style.visibility = 'hidden';
|
|
||||||
} else {
|
|
||||||
info.el.style.display = 'block';
|
|
||||||
info.el.style.visibility = 'visible';
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
eventSourceSuccess: function(content, xhr) {
|
eventSourceSuccess: function(content, xhr) {
|
||||||
// This runs after events are successfully loaded from the API
|
// This runs after events are successfully loaded from the API
|
||||||
@@ -1516,37 +1505,22 @@
|
|||||||
function filterEvents() {
|
function filterEvents() {
|
||||||
const events = calendar.getEvents();
|
const events = calendar.getEvents();
|
||||||
events.forEach(event => {
|
events.forEach(event => {
|
||||||
const eventEl = event.el;
|
const eventEl = calendar.getEventById(event.id);
|
||||||
if (eventEl) {
|
if (eventEl) {
|
||||||
if (selectedVehicle === 'all' || event.extendedProps.vehicle === selectedVehicle) {
|
if (selectedVehicle === 'all' || event.extendedProps.vehicle === selectedVehicle) {
|
||||||
eventEl.style.display = 'block';
|
// Show event
|
||||||
eventEl.style.visibility = 'visible';
|
eventEl.setProp('display', 'auto');
|
||||||
} else {
|
} else {
|
||||||
eventEl.style.display = 'none';
|
// Hide event
|
||||||
eventEl.style.visibility = 'hidden';
|
eventEl.setProp('display', 'none');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateReservationsList();
|
updateReservationsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update vehicle filter buttons to show active state
|
// Update eventDidMount to not handle filtering
|
||||||
document.querySelectorAll('.vehicle-filter-btn').forEach(btn => {
|
// (eventDidMount is already defined in calendarConfig above)
|
||||||
btn.addEventListener('click', function() {
|
|
||||||
// Update active state
|
|
||||||
document.querySelectorAll('.vehicle-filter-btn').forEach(b => {
|
|
||||||
b.classList.remove('active');
|
|
||||||
b.querySelector('.vehicle-badge').classList.remove('ring-2', 'ring-brand-blue');
|
|
||||||
});
|
|
||||||
|
|
||||||
this.classList.add('active');
|
|
||||||
this.querySelector('.vehicle-badge').classList.add('ring-2', 'ring-brand-blue');
|
|
||||||
|
|
||||||
// Update selected vehicle and filter
|
|
||||||
selectedVehicle = this.dataset.vehicle;
|
|
||||||
filterEvents();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fix reservation form show function
|
// Fix reservation form show function
|
||||||
function showReservationForm(date) {
|
function showReservationForm(date) {
|
||||||
|
|||||||
Reference in New Issue
Block a user