From b98e38b38b8d699336453eef3566daea72142f36 Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Sat, 25 Oct 2025 22:11:44 +0200 Subject: [PATCH] enhanced MyLoansPage with confirmation dialog for loan deletion; improved table layout and added code formatting for loan codes --- FrontendV2/src/pages/MyLoansPage.tsx | 100 ++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/FrontendV2/src/pages/MyLoansPage.tsx b/FrontendV2/src/pages/MyLoansPage.tsx index 4c18144..bcde82c 100644 --- a/FrontendV2/src/pages/MyLoansPage.tsx +++ b/FrontendV2/src/pages/MyLoansPage.tsx @@ -2,7 +2,18 @@ import { useEffect, useState } from "react"; import Cookies from "js-cookie"; import { useNavigate } from "react-router-dom"; import MyAlert from "@/components/myChakra/MyAlert"; -import { Container, VStack, Spinner, Text, Table } from "@chakra-ui/react"; +import { + Container, + VStack, + Spinner, + Text, + Table, + Button, + CloseButton, + Dialog, + Portal, + Code, +} from "@chakra-ui/react"; import { Header } from "@/components/Header"; import { Trash2 } from "lucide-react"; @@ -17,6 +28,8 @@ export const MyLoansPage = () => { const [loans, setLoans] = useState([]); const [isLoading, setIsLoading] = useState(false); + const [delLoanCode, setDelLoanCode] = useState(null); + // Error handling states const [isMsg, setIsMsg] = useState(false); const [msgStatus, setMsgStatus] = useState<"error" | "success">("error"); @@ -123,11 +136,26 @@ export const MyLoansPage = () => { )} {loans && ( - + - - - + {/* Ausleihcode */} + + {/* Startdatum */} + + {/* Enddatum */} + + {/* Geräte (flexibler) */} + + {/* Ausleihdatum */} + + {/* Rückgabedatum */} + + {/* Aktionen */} + @@ -143,16 +171,68 @@ export const MyLoansPage = () => { {loans.map((loan) => ( - {loan.loan_code} + + + {`${loan.loan_code}`} + + {formatDate(loan.start_date)} {formatDate(loan.end_date)} - {loan.loaned_items_name} + + + {loan.loaned_items_name} + + {formatDate(loan.take_date)} {formatDate(loan.returned_date)} - + + + + + + + + + + Sicher? + + + + Möchtest du die Ausleihe mit dem{" "} + {delLoanCode} Code wirklich + löschen? +
+ Für den Admin bleibt sie weiterhin sichtbar. +
+
+ + + + + + + + + +
+
+
+
))}