From a8f409cc149ceb632fe4ef7b7786b32eea97e833 Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Thu, 9 Oct 2025 11:35:43 +0000 Subject: [PATCH] updated showing reservations in assetmanagement --- .../pages/AssetManagement/AssetManagement.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/public/js/pages/AssetManagement/AssetManagement.js b/public/js/pages/AssetManagement/AssetManagement.js index 9bc533915..0049a9a54 100644 --- a/public/js/pages/AssetManagement/AssetManagement.js +++ b/public/js/pages/AssetManagement/AssetManagement.js @@ -311,16 +311,20 @@ Vue.component('asset-borrow-return-widget', { }, nextReservation() { if (!this.rowData.reservations || this.rowData.reservations.length === 0) return null; - const now = window.moment().unix(); - return this.rowData.reservations.reduce((closest, current) => { - const closestDiff = Math.abs(closest.startDate - now); - const currentDiff = Math.abs(current.startDate - now); - return currentDiff < closestDiff ? current : closest; + // Filter for reservations starting in the future + const upcomingReservations = this.rowData.reservations.filter(r => r.startDate > now); + + if (upcomingReservations.length === 0) { + return null; + } + + // Of the upcoming reservations, find the one that starts soonest + return upcomingReservations.reduce((earliest, current) => { + return current.startDate < earliest.startDate ? current : earliest; }); } - }, methods: { formatDate(timestamp, format) { @@ -755,4 +759,4 @@ Vue.component('asset-reservation-modal', { this.isPermanent = false; } } -}); \ No newline at end of file +});