refactor: update API endpoints and enhance loan management features

This commit is contained in:
2025-11-17 22:49:54 +01:00
parent 88a2c74e88
commit 084a0fa2e2
13 changed files with 209 additions and 20 deletions

View File

@@ -39,6 +39,8 @@ type Device = {
can_borrow_role: string;
inSafe: number;
entry_created_at: string;
last_borrowed_person: string | null;
currently_borrowing: string | null;
};
const Landingpage: React.FC = () => {
@@ -68,7 +70,7 @@ const Landingpage: React.FC = () => {
const fetchData = async () => {
setIsLoading(true);
try {
const loanRes = await fetch(`${API_BASE}/apiV2/allLoans`);
const loanRes = await fetch(`${API_BASE}/api/loans/all-loans`);
const loanData = await loanRes.json();
if (Array.isArray(loanData)) {
setLoans(loanData);
@@ -80,7 +82,7 @@ const Landingpage: React.FC = () => {
);
}
const deviceRes = await fetch(`${API_BASE}/apiV2/allItems`);
const deviceRes = await fetch(`${API_BASE}/api/loans/all-items`);
const deviceData = await deviceRes.json();
if (Array.isArray(deviceData)) {
setDevices(deviceData);
@@ -200,6 +202,14 @@ const Landingpage: React.FC = () => {
<Text>
{t("rent-role")}: {device.can_borrow_role}
</Text>
<Text>
{t("last-borrowed-person")}:{" "}
{device.last_borrowed_person || "N/A"}
</Text>
<Text>
{t("currently-borrowed-by")}:{" "}
{device.currently_borrowing || "N/A"}
</Text>
</Card.Body>
</Card.Root>
))}