This commit is contained in:
Tomas Dvorak
2025-06-11 21:48:42 +02:00
parent 48b1e90063
commit 1ef562c550
+19 -12
View File
@@ -4306,16 +4306,23 @@ function displayReservations(reservations) {
return; return;
} }
tbody.innerHTML = reservations.map(res => ` tbody.innerHTML = reservations.map(res => {
<tr class="hover:bg-gray-50"> const startDate = new Date(res.start);
<td class="px-6 py-4">${res.driverName}</td> const endDate = new Date(res.end);
<td class="px-6 py-4">${res.vehicle}</td> const formattedStart = startDate.toLocaleString('cs-CZ');
<td class="px-6 py-4">${formatDateTime(res.startDate, res.startTime)}</td> const formattedEnd = endDate.toLocaleString('cs-CZ');
<td class="px-6 py-4">${formatDateTime(res.endDate, res.endTime)}</td>
<td class="px-6 py-4">${res.purpose || '-'}</td> return `
<td class="px-6 py-4">${calculateDuration(res)}</td> <tr class="hover:bg-gray-50">
</tr> <td class="px-6 py-4">${res.driverName || '-'}</td>
`).join(''); <td class="px-6 py-4">${res.vehicle || '-'}</td>
<td class="px-6 py-4">${formattedStart}</td>
<td class="px-6 py-4">${formattedEnd}</td>
<td class="px-6 py-4">${res.purpose || '-'}</td>
<td class="px-6 py-4">${calculateDuration(res)}</td>
</tr>
`;
}).join('');
} }
// Function to filter reservations // Function to filter reservations
@@ -4391,8 +4398,8 @@ function formatDateTime(date, time) {
// Helper function to calculate duration // Helper function to calculate duration
function calculateDuration(reservation) { function calculateDuration(reservation) {
const start = new Date(`${reservation.startDate}T${reservation.startTime}`); const start = new Date(reservation.start);
const end = new Date(`${reservation.endDate}T${reservation.endTime}`); const end = new Date(reservation.end);
const diff = end - start; const diff = end - start;
const days = Math.floor(diff / (1000 * 60 * 60 * 24)); const days = Math.floor(diff / (1000 * 60 * 60 * 24));