Compare commits
2 Commits
a8821ceca8
...
9daff3ea5c
| Author | SHA1 | Date | |
|---|---|---|---|
| 9daff3ea5c | |||
| 71fea52da7 |
@@ -3,7 +3,6 @@ import { useEffect } from "react";
|
||||
import Dashboard from "./Dashboard";
|
||||
import Login from "./Login";
|
||||
import Cookies from "js-cookie";
|
||||
import Landingpage from "@/components/API/Landingpage";
|
||||
|
||||
const API_BASE =
|
||||
(import.meta as any).env?.VITE_BACKEND_URL ||
|
||||
@@ -12,16 +11,8 @@ const API_BASE =
|
||||
|
||||
const Layout: React.FC = () => {
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
const [showAPI, setShowAPI] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const path = window.location.pathname.replace(/\/+$/, ""); // remove trailing slash
|
||||
if (path === "/api") {
|
||||
setShowAPI(true);
|
||||
console.log("signal");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cookies.get("token")) {
|
||||
const verifyToken = async () => {
|
||||
const response = await fetch(`${API_BASE}/api/verifyToken`, {
|
||||
@@ -48,14 +39,6 @@ const Layout: React.FC = () => {
|
||||
setIsLoggedIn(false);
|
||||
};
|
||||
|
||||
if (showAPI) {
|
||||
return (
|
||||
<main>
|
||||
<Landingpage />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<main>
|
||||
{isLoggedIn ? (
|
||||
|
||||
@@ -149,7 +149,7 @@ const ItemTable: React.FC = () => {
|
||||
</HStack>
|
||||
{/* End action toolbar */}
|
||||
|
||||
<Heading marginBottom={4} size="md">
|
||||
<Heading marginBottom={4} size="2xl">
|
||||
Gegenstände
|
||||
</Heading>
|
||||
{isError && (
|
||||
|
||||
@@ -54,6 +54,7 @@ const LoanTable: React.FC = () => {
|
||||
returned_date: string;
|
||||
created_at: string;
|
||||
loaned_items_name: string[];
|
||||
deleted: boolean;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -108,9 +109,13 @@ const LoanTable: React.FC = () => {
|
||||
</HStack>
|
||||
{/* End action toolbar */}
|
||||
|
||||
<Heading marginBottom={4} size="md">
|
||||
<Heading marginBottom={4} size="2xl">
|
||||
Ausleihen
|
||||
</Heading>
|
||||
<Text>
|
||||
Die Ausleihen die rot sind, wurden gelöscht und sind nur für den Admin
|
||||
sichtbar.
|
||||
</Text>
|
||||
|
||||
{isError && (
|
||||
<MyAlert
|
||||
@@ -163,7 +168,7 @@ const LoanTable: React.FC = () => {
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{items.map((item) => (
|
||||
<Table.Row key={item.id}>
|
||||
<Table.Row color={item.deleted ? "red" : "white"} key={item.id}>
|
||||
<Table.Cell>{item.id}</Table.Cell>
|
||||
<Table.Cell>{item.username}</Table.Cell>
|
||||
<Table.Cell>
|
||||
|
||||
@@ -144,7 +144,7 @@ const UserTable: React.FC = () => {
|
||||
</HStack>
|
||||
{/* End action toolbar */}
|
||||
|
||||
<Heading marginBottom={4} size="md">
|
||||
<Heading marginBottom={4} size="2xl">
|
||||
Benutzer
|
||||
</Heading>
|
||||
{changePWform && (
|
||||
|
||||
@@ -179,6 +179,7 @@ export const getBorrowableItemsFromDatabase = async (
|
||||
FROM loans l
|
||||
JOIN JSON_TABLE(l.loaned_items_id, '$[*]' COLUMNS (item_id INT PATH '$')) jt
|
||||
WHERE jt.item_id = i.id
|
||||
AND l.deleted = 0
|
||||
AND l.start_date < ?
|
||||
AND COALESCE(l.returned_date, l.end_date) > ?
|
||||
);
|
||||
@@ -269,6 +270,7 @@ export const createLoanInDatabase = async (
|
||||
JOIN JSON_TABLE(l.loaned_items_id, '$[*]' COLUMNS (item_id INT PATH '$')) jt
|
||||
ON TRUE
|
||||
WHERE jt.item_id IN (?)
|
||||
AND l.deleted = 0
|
||||
AND l.start_date < ?
|
||||
AND COALESCE(l.returned_date, l.end_date) > ?
|
||||
`,
|
||||
|
||||
Reference in New Issue
Block a user