import React from "react"; import { useEffect } from "react"; import { useState } from "react"; import { Spinner, Text, VStack, Box } from "@chakra-ui/react"; import { Table, Heading } from "@chakra-ui/react"; import { formatDateTime } from "@/utils/userFuncs"; const Landingpage: React.FC = () => { const [isLoading, setIsLoading] = useState(false); const [loans, setLoans] = useState([]); useEffect(() => { setIsLoading(true); fetch("http://localhost:8002/apiV2/allLoans") .then((response) => response.json()) .then((data) => { setLoans(data); setIsLoading(false); }) .catch((error) => { console.error("Error fetching loans:", error); setIsLoading(false); }); }, []); return ( <> Matthias-Claudius-Schule Technik Alle Ausleihen {isLoading && ( Loading... )} {!isLoading && ( # Username Start Date End Date Loaned Items Returned Date Take Date {loans.map((loan) => ( {loan.id} {loan.username} {formatDateTime(loan.start_date)} {formatDateTime(loan.end_date)} {loan.loaned_items_name} {formatDateTime(loan.returned_date)} {formatDateTime(loan.take_date)} ))} )} ); }; export default Landingpage;