mirror of
https://github.com/Alvin-Zilverstand/Challenge_15_Magazijn_App_Maken.git
synced 2026-03-06 11:06:34 +01:00
Enhance reservation management: add 'Mark Returned' button and update return status handling
This commit is contained in:
@@ -83,7 +83,9 @@ function filterAndDisplayReservations() {
|
||||
<i class="bi bi-x-lg"></i><span class="btn-text"> Reject Return</span>
|
||||
</button>
|
||||
` : reservation.status === 'APPROVED' ? `
|
||||
<span class="text-success"><i class="bi bi-check-circle"></i><span class="btn-text"> Currently Borrowed</span></span>
|
||||
<button class="btn btn-info" onclick="updateReservation('${reservation._id}', 'RETURNED')" title="Mark as Returned">
|
||||
<i class="bi bi-arrow-return-left"></i><span class="btn-text"> Mark Returned</span>
|
||||
</button>
|
||||
` : reservation.status === 'RETURNED' ? `
|
||||
<button class="btn btn-secondary" onclick="archiveReservation('${reservation._id}')" title="Archive Reservation">
|
||||
<i class="bi bi-archive"></i><span class="btn-text"> Archive</span>
|
||||
|
||||
@@ -150,7 +150,11 @@ router.patch('/:id', auth, async (req, res) => {
|
||||
item.reserved = Math.max(0, item.reserved - (reservation.quantity || 1));
|
||||
await item.save();
|
||||
} else if (oldStatus === 'RETURN_PENDING' && newStatus === 'RETURNED') {
|
||||
// Admin approved the return
|
||||
// Admin approved the return request
|
||||
item.reserved = Math.max(0, item.reserved - (reservation.quantity || 1));
|
||||
await item.save();
|
||||
} else if (oldStatus === 'APPROVED' && newStatus === 'RETURNED') {
|
||||
// Admin directly marked approved item as returned
|
||||
item.reserved = Math.max(0, item.reserved - (reservation.quantity || 1));
|
||||
await item.save();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user