Skip to content

Commit e034a14

Browse files
feat(user/admin): add extend request manager and request extend book
1 parent 2bc3822 commit e034a14

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

web/WEB-INF/views/admin/extend_request_manager.jsp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,17 @@
726726

727727
<!-- ==== MAIN ==== -->
728728
<main>
729+
<form id="approveForm" method="get" action="${pageContext.request.contextPath}/admin/approve-request">
730+
<input type="hidden" name="account" id="approveAccount">
731+
<input type="hidden" name="title" id="approveTitle">
732+
<input type="hidden" name="cover" id="approveCover">
733+
</form>
734+
735+
<form id="rejectForm" method="get" action="${pageContext.request.contextPath}/admin/reject-request">
736+
<input type="hidden" name="account" id="rejectAccount">
737+
<input type="hidden" name="title" id="rejectTitle">
738+
<input type="hidden" name="cover" id="approveCover">
739+
</form>
729740
<div class="page-title">
730741
<h2>Manage Extend Requests</h2>
731742
</div>
@@ -774,12 +785,12 @@
774785

775786
<td>
776787
<c:choose>
777-
<c:when test="${r.status == 'PENDING'}">
788+
<c:when test="${r.status == 'pending'}">
778789
<span class="status-badge status-inactive">
779790
<i class="fa-solid fa-hourglass-half"></i> Pending
780791
</span>
781792
</c:when>
782-
<c:when test="${r.status == 'APPROVED'}">
793+
<c:when test="${r.status == 'approved'}">
783794
<span class="status-badge status-active">
784795
<i class="fa-solid fa-circle-check"></i> Approved
785796
</span>
@@ -791,9 +802,9 @@
791802
</c:otherwise>
792803
</c:choose>
793804
</td>
794-
<td>
805+
<td>
795806
<div class="actions">
796-
<button class="btn btn-success btn-sm" onclick="approveRequest('${r.account}', '${r.title}')">
807+
<button class="btn btn-success btn-sm" onclick="approveRequest('${r.account}', '${r.title}', '${r.coverImage}')">
797808
<i class="fa-solid fa-check"></i> Approve
798809
</button>
799810
<button class="btn btn-danger btn-sm" onclick="rejectRequest('${r.account}', '${r.title}')">
@@ -826,19 +837,24 @@
826837
window.location.href = '${pageContext.request.contextPath}/admin/extend-request-manger?search=' + encodeURIComponent(val);
827838
}
828839
829-
function approveRequest(account, title) {
840+
function approveRequest(account, title, cover) {
830841
if (confirm(`Approve extend request for "${title}" by ${account}?`)) {
831-
alert("Approved (demo)");
832-
// TODO: gọi servlet xử lý POST approve
842+
document.getElementById("approveAccount").value = account;
843+
document.getElementById("approveTitle").value = title;
844+
document.getElementById("approveCover").value = cover;
845+
document.getElementById("approveForm").submit();
833846
}
834847
}
835848
836-
function rejectRequest(account, title) {
849+
function rejectRequest(account, title, cover) {
837850
if (confirm(`Reject extend request for "${title}" by ${account}?`)) {
838-
alert("Rejected (demo)");
839-
// TODO: gọi servlet xử lý POST reject
851+
document.getElementById("rejectAccount").value = account;
852+
document.getElementById("rejectTitle").value = title;
853+
document.getElementById("approveCover").value = cover;
854+
document.getElementById("rejectForm").submit();
840855
}
841856
}
857+
842858
</script>
843859
</body>
844860

web/WEB-INF/views/borrowing/borrowedbooks.jsp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<%@page contentType="text/html" pageEncoding="UTF-8"%>
22
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
3+
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
4+
35
<!DOCTYPE html>
46
<html>
57
<head>
@@ -291,12 +293,22 @@
291293

292294
<p><strong>Borrow Date:</strong> ${book.borrowDate}</p>
293295
<p><strong>Due Date:</strong> ${book.dueDate}</p>
294-
296+
<c:choose>
297+
<c:when test="${book.extendTime >= 5}">
298+
<p><strong>Extensions:</strong>
299+
<span style="color:red">${book.extendTime} / 5 (Maxed Out)</span>
300+
</p>
301+
</c:when>
302+
<c:otherwise>
303+
<p><strong>Extensions:</strong> ${book.extendTime} / 5</p>
304+
</c:otherwise>
305+
</c:choose>
295306
<div class="btn-group">
296307
<a href="${pageContext.request.contextPath}/borrowing/return?slug=${book.slug}" class="btn return">Return Book</a>
297308
<button class="btn extend" onclick="document.getElementById('extendBox${loop.index}').style.display = 'block'">Extend</button>
298309
</div>
299310

311+
300312
<!-- Extend form -->
301313
<div id="extendBox${loop.index}"
302314
class="extend-box"
@@ -305,12 +317,16 @@
305317
<c:if test="${not empty error && targetBookID == book.bookID}">
306318
<p style="color: #ef4444; font-weight: 600; margin-bottom: 8px;">
307319
${error}
308-
<a href="${pageContext.request.contextPath}/user/request-extend-book">Gia hạn sách</a>
320+
<div style="margin-top:18px;text-align:center;">
321+
<a href="${pageContext.request.contextPath}/user/request-extend-book"
322+
style="color:#2563eb;font-weight:600;text-decoration:none;">
323+
→ If you’ve run out of renewals, you can request an extension via email.
324+
</a>
325+
</div>
309326
</p>
310327
<c:remove var="error" scope="session" />
311328
</c:if>
312329

313-
314330
<form action="${pageContext.request.contextPath}/borrowing/extend" method="post">
315331
<label>Choose new due date:</label><br>
316332
<input type="date" name="newDueDate" min="${book.borrowDate}" required>
@@ -321,7 +337,7 @@
321337
onclick="this.closest('.extend-box').style.display = 'none'">Cancel</button>
322338
</div>
323339
</form>
324-
</div>
340+
</div>
325341
</dialog>
326342
</c:forEach>
327343
</div>

0 commit comments

Comments
 (0)