From 6577e7ee2de20f74c09302321c5d218535cda866 Mon Sep 17 00:00:00 2001 From: Pascal Euhus Date: Fri, 20 Oct 2023 22:08:20 +0200 Subject: [PATCH] FORMAT --- src/main/webui/src/components/AppRouter.tsx | 12 ++--- .../src/components/context/UserContext.tsx | 48 +++++++++++-------- .../webui/src/components/layout/Header.tsx | 12 ++--- .../src/components/nav/NavigationDrawer.tsx | 32 ++++++------- src/main/webui/src/index.tsx | 26 +++++----- src/main/webui/src/types/index.ts | 2 +- src/main/webui/src/util/DateUtil.test.ts | 35 +++++++------- src/main/webui/src/util/DateUtil.ts | 14 +++--- src/main/webui/src/views/404.tsx | 27 ++++++----- src/main/webui/src/views/ManagementView.tsx | 28 ++++++----- src/main/webui/src/views/ModuleDetails.tsx | 6 +-- src/main/webui/src/views/ProviderDetails.tsx | 6 +-- 12 files changed, 128 insertions(+), 120 deletions(-) diff --git a/src/main/webui/src/components/AppRouter.tsx b/src/main/webui/src/components/AppRouter.tsx index 89085e90..62922da3 100644 --- a/src/main/webui/src/components/AppRouter.tsx +++ b/src/main/webui/src/components/AppRouter.tsx @@ -5,18 +5,19 @@ import ModuleDetails from "../views/ModuleDetails"; import ProviderOverview from "../views/ProviderOverview"; import ProviderDetails from "../views/ProviderDetails"; import ManagementView from "../views/ManagementView"; -import {useUserContext} from "./context/UserContext"; +import { useUserContext } from "./context/UserContext"; import NotFoundPage from "../views/404"; const AppRouter = () => { - const { isAdmin } = useUserContext(); return ( } /> } /> - { isAdmin ? } /> : null } + {isAdmin ? ( + } /> + ) : null} { @@ -35,10 +36,7 @@ const AppRouter = () => { }} element={} /> - } - /> + } /> ); diff --git a/src/main/webui/src/components/context/UserContext.tsx b/src/main/webui/src/components/context/UserContext.tsx index 9443165f..28e8881f 100644 --- a/src/main/webui/src/components/context/UserContext.tsx +++ b/src/main/webui/src/components/context/UserContext.tsx @@ -1,32 +1,38 @@ -import React, {useContext, useState} from "react"; -import {User} from "../../types"; +import React, { useContext, useState } from "react"; +import { User } from "../../types"; interface IUserContext { - user: User, - isAdmin: boolean, + user: User; + isAdmin: boolean; } const defaultContext: IUserContext = { - user: {} as User, - isAdmin: false, -} + user: {} as User, + isAdmin: false, +}; const UserContext = React.createContext(defaultContext); -export const UserProvider = ({ fetchedUser, children }: {fetchedUser: User, children: any}) => { - const [user, setUser] = useState(fetchedUser); - const [isAdmin, setIsAdmin] = useState(fetchedUser.roles.includes("admin")); +export const UserProvider = ({ + fetchedUser, + children, +}: { + fetchedUser: User; + children: any; +}) => { + const [user, setUser] = useState(fetchedUser); + const [isAdmin, setIsAdmin] = useState(fetchedUser.roles.includes("admin")); - return ( - - {children} - - ); + return ( + + {children} + + ); }; -export const useUserContext = () => useContext(UserContext); \ No newline at end of file +export const useUserContext = () => useContext(UserContext); diff --git a/src/main/webui/src/components/layout/Header.tsx b/src/main/webui/src/components/layout/Header.tsx index 606f1c92..fd3256d2 100644 --- a/src/main/webui/src/components/layout/Header.tsx +++ b/src/main/webui/src/components/layout/Header.tsx @@ -3,13 +3,13 @@ import AppBar from "@mui/material/AppBar"; import Box from "@mui/material/Box"; import Toolbar from "@mui/material/Toolbar"; import Typography from "@mui/material/Typography"; -import {useUserContext} from "../context/UserContext"; -import {Avatar} from "@mui/material"; -import {deepOrange} from "@mui/material/colors"; +import { useUserContext } from "../context/UserContext"; +import { Avatar } from "@mui/material"; +import { deepOrange } from "@mui/material/colors"; const Header = () => { - const { user} = useUserContext(); - return ( + const { user } = useUserContext(); + return ( @@ -41,4 +41,4 @@ export default Header; {user.name ? user.name.charAt(0).toUpperCase() : undefined} - */ \ No newline at end of file + */ diff --git a/src/main/webui/src/components/nav/NavigationDrawer.tsx b/src/main/webui/src/components/nav/NavigationDrawer.tsx index 11fa47f2..af4985e4 100644 --- a/src/main/webui/src/components/nav/NavigationDrawer.tsx +++ b/src/main/webui/src/components/nav/NavigationDrawer.tsx @@ -12,7 +12,7 @@ import { import ViewModuleIcon from "@mui/icons-material/ViewModule"; import AppsIcon from "@mui/icons-material/Apps"; import KeyIcon from "@mui/icons-material/Key"; -import {useUserContext} from "../context/UserContext"; +import { useUserContext } from "../context/UserContext"; const NavigationDrawer = () => { const { isAdmin } = useUserContext(); @@ -63,21 +63,21 @@ const NavigationDrawer = () => { - { isAdmin ? - - - - - - - - : null - } + {isAdmin ? ( + + + + + + + + + ) : null} ); diff --git a/src/main/webui/src/index.tsx b/src/main/webui/src/index.tsx index b947db17..b103ef1f 100644 --- a/src/main/webui/src/index.tsx +++ b/src/main/webui/src/index.tsx @@ -11,11 +11,11 @@ import AppRouter from "./components/AppRouter"; import CssBaseline from "@mui/material/CssBaseline"; import { Box, Stack } from "@mui/material"; import NavigationDrawer from "./components/nav/NavigationDrawer"; -import {UserProvider} from "./components/context/UserContext"; +import { UserProvider } from "./components/context/UserContext"; const fetchUser = async () => { - const response = await fetch('/tapir/user'); - return await response.json(); + const response = await fetch("/tapir/user"); + return await response.json(); }; const user = await fetchUser(); @@ -26,15 +26,15 @@ const root = ReactDOM.createRoot( root.render( - -
- - - - - - -