Merge branch 'AssetManagement/fix-reservation-lookup' into 'master'
fixed showing closest reservation See merge request fronk/thetool!1743
This commit is contained in:
@@ -311,9 +311,16 @@ 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.find(r => r.startDate > now);
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
formatDate(timestamp, format) {
|
||||
|
||||
Reference in New Issue
Block a user