refactor: update @tanstack/react-query to version 5.90.5 and restructure Footer component

feat: edited imports
This commit is contained in:
2025-10-30 17:27:35 +01:00
parent 0d3de4f705
commit b52fe07618
11 changed files with 80 additions and 94 deletions

View File

@@ -11,7 +11,7 @@
"@chakra-ui/react": "^3.28.0", "@chakra-ui/react": "^3.28.0",
"@emotion/react": "^11.14.0", "@emotion/react": "^11.14.0",
"@tailwindcss/vite": "^4.1.11", "@tailwindcss/vite": "^4.1.11",
"@tanstack/react-query": "^5.85.5", "@tanstack/react-query": "^5.90.5",
"i18next": "^25.6.0", "i18next": "^25.6.0",
"jotai": "^2.15.0", "jotai": "^2.15.0",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",

View File

@@ -13,7 +13,7 @@
"@chakra-ui/react": "^3.28.0", "@chakra-ui/react": "^3.28.0",
"@emotion/react": "^11.14.0", "@emotion/react": "^11.14.0",
"@tailwindcss/vite": "^4.1.11", "@tailwindcss/vite": "^4.1.11",
"@tanstack/react-query": "^5.85.5", "@tanstack/react-query": "^5.90.5",
"i18next": "^25.6.0", "i18next": "^25.6.0",
"jotai": "^2.15.0", "jotai": "^2.15.0",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",

View File

@@ -13,12 +13,11 @@ import { MyLoansPage } from "./pages/MyLoansPage";
import Landingpage from "./pages/Landingpage"; import Landingpage from "./pages/Landingpage";
import { changeLanguage } from "i18next"; import { changeLanguage } from "i18next";
import { Box, Flex } from "@chakra-ui/react"; import { Box, Flex } from "@chakra-ui/react";
import { Footer } from "./components/Footer"; import { Footer } from "./components/footer/Footer";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { API_BASE } from "@/config/api.config";
const API_BASE = const queryClient = new QueryClient();
(import.meta as any).env?.VITE_BACKEND_URL ||
import.meta.env.VITE_BACKEND_URL ||
"http://localhost:8002";
function App() { function App() {
const [user, setUser] = useState<User | undefined>(undefined); const [user, setUser] = useState<User | undefined>(undefined);
@@ -65,6 +64,7 @@ function App() {
}, []); }, []);
return ( return (
<QueryClientProvider client={queryClient}>
<Flex direction="column" minH="100vh"> <Flex direction="column" minH="100vh">
<Box as="main" flex="1"> <Box as="main" flex="1">
<UserContext.Provider value={user}> <UserContext.Provider value={user}>
@@ -83,6 +83,7 @@ function App() {
</Box> </Box>
<Footer /> <Footer />
</Flex> </Flex>
</QueryClientProvider>
); );
} }

View File

@@ -1,43 +0,0 @@
import { Box } from "@chakra-ui/react";
import { useEffect } from "react";
import { infoAtom } from "@/states/Atoms";
import { useAtom } from "jotai";
const API_BASE =
(import.meta as any).env?.VITE_BACKEND_URL ||
import.meta.env.VITE_BACKEND_URL ||
"http://localhost:8002";
export const Footer = () => {
const [info, setInfo] = useAtom(infoAtom);
useEffect(() => {
const metaData = async () => {
const response = await fetch(`${API_BASE}/server-info`, {
method: "GET",
});
if (response.ok) {
const data = await response.json();
setInfo(data);
}
};
metaData();
}, []);
return (
<Box
as="footer"
py={4}
textAlign="center"
position="fixed"
bottom="0"
left="0"
right="0"
>
Made with by Theis Gaedigk - Year 2019 at MCS-Bochum
<br />
Frontend-Version: {info ? info["frontend-info"].version : "N/A"} |
Backend-Version: {info ? info["backend-info"].version : "N/A"}
</Box>
);
};

View File

@@ -32,11 +32,7 @@ import { useUserContext } from "@/states/Context";
import { useState } from "react"; import { useState } from "react";
import MyAlert from "./myChakra/MyAlert"; import MyAlert from "./myChakra/MyAlert";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { API_BASE } from "@/config/api.config";
const API_BASE =
(import.meta as any).env?.VITE_BACKEND_URL ||
import.meta.env.VITE_BACKEND_URL ||
"http://localhost:8002";
export const Header = () => { export const Header = () => {
const navigate = useNavigate(); const navigate = useNavigate();

View File

@@ -0,0 +1,23 @@
import { Box } from "@chakra-ui/react";
import { useVersionInfoQuery } from "./versionInfo.query";
export const Footer = () => {
const { data: info } = useVersionInfoQuery();
return (
<Box
as="footer"
py={4}
textAlign="center"
position="fixed"
bottom="0"
left="0"
right="0"
>
Made with by Theis Gaedigk - Year 2019 at MCS-Bochum
<br />
Frontend-Version: {info ? info["frontend-info"].version : "N/A"} |
Backend-Version: {info ? info["backend-info"].version : "N/A"}
</Box>
);
};

View File

@@ -0,0 +1,25 @@
import { useQuery } from "@tanstack/react-query";
import { API_BASE } from "@/config/api.config";
export const useVersionInfoQuery = () =>
useQuery({
queryKey: ["versionInfo"],
queryFn: async () => {
const response = await fetch(`${API_BASE}/server-info`, {
method: "GET",
});
if (response.ok) {
const data = await response.json();
return data;
} else {
return {
"backend-info": {
version: "N/A",
},
"frontend-info": {
version: "N/A",
},
};
}
},
});

View File

@@ -13,6 +13,7 @@ import {
import { Lock, LockOpen } from "lucide-react"; import { Lock, LockOpen } from "lucide-react";
import MyAlert from "@/components/myChakra/MyAlert"; import MyAlert from "@/components/myChakra/MyAlert";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { API_BASE } from "@/config/api.config";
export const formatDateTime = (value: string | null | undefined) => { export const formatDateTime = (value: string | null | undefined) => {
if (!value) return "N/A"; if (!value) return "N/A";
@@ -22,11 +23,6 @@ export const formatDateTime = (value: string | null | undefined) => {
return `${d}.${M}.${y} ${h}:${min} Uhr`; return `${d}.${M}.${y} ${h}:${min} Uhr`;
}; };
const API_BASE =
(import.meta as any).env?.VITE_BACKEND_URL ||
import.meta.env.VITE_BACKEND_URL ||
"http://localhost:8002";
type Loan = { type Loan = {
id: number; id: number;
username: string; username: string;

View File

@@ -7,12 +7,8 @@ import Cookies from "js-cookie";
import { Navigate, useNavigate } from "react-router-dom"; import { Navigate, useNavigate } from "react-router-dom";
import { PasswordInput } from "@/components/ui/password-input"; import { PasswordInput } from "@/components/ui/password-input";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Footer } from "@/components/Footer"; import { Footer } from "@/components/footer/Footer";
import { API_BASE } from "@/config/api.config";
const API_BASE =
(import.meta as any).env?.VITE_BACKEND_URL ||
import.meta.env.VITE_BACKEND_URL ||
"http://localhost:8002";
export const LoginPage = () => { export const LoginPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -24,7 +20,7 @@ export const LoginPage = () => {
useEffect(() => { useEffect(() => {
if (isLoggedIn) { if (isLoggedIn) {
navigate("/", { replace: true }); navigate("/", { replace: true });
window.location.reload(); // Mit Tobais besprechen, ob das so bleiben soll window.location.reload(); // Wenn entfernt: Seite bleibt schwarz und muss manuell neu geladen werden
} }
}, [isLoggedIn, navigate]); }, [isLoggedIn, navigate]);

View File

@@ -17,11 +17,7 @@ import {
import { Header } from "@/components/Header"; import { Header } from "@/components/Header";
import { Trash2 } from "lucide-react"; import { Trash2 } from "lucide-react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { API_BASE } from "@/config/api.config";
const API_BASE =
(import.meta as any).env?.VITE_BACKEND_URL ||
import.meta.env.VITE_BACKEND_URL ||
"http://localhost:8002";
export const MyLoansPage = () => { export const MyLoansPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@@ -1,8 +1,5 @@
import Cookies from "js-cookie"; import Cookies from "js-cookie";
const API_BASE = import { API_BASE } from "@/config/api.config";
(import.meta as any).env?.VITE_BACKEND_URL ||
import.meta.env.VITE_BACKEND_URL ||
"http://localhost:8002";
export const getBorrowableItems = async ( export const getBorrowableItems = async (
startDate: string, startDate: string,
@@ -30,7 +27,6 @@ export const getBorrowableItems = async (
} }
const data = await response.json(); const data = await response.json();
console.log(data);
return { return {
data: data, data: data,
status: "success", status: "success",