clean up unused js parts

This commit is contained in:
Johannes Kirschbauer
2023-10-03 10:39:49 +02:00
parent 7c1e04a7d6
commit b27dad1cc4
24 changed files with 135 additions and 201 deletions

View File

@@ -0,0 +1,5 @@
import JoinPrequel from "@/views/joinPrequel";
export default function Page() {
return <JoinPrequel />;
}

View File

@@ -11,7 +11,7 @@ import {
useMediaQuery,
useTheme,
} from "@mui/material";
import { ChangeEvent, useState } from "react";
import { useState } from "react";
import { Toaster } from "react-hot-toast";
import { StyledEngineProvider } from "@mui/material/styles";
@@ -25,10 +25,10 @@ import axios from "axios";
import {
AppContext,
WithAppState,
useAppState,
// useAppState,
} from "@/components/hooks/useAppContext";
import Background from "@/components/background";
import { usePathname, redirect } from "next/navigation";
// import { usePathname, redirect } from "next/navigation";
const roboto = localFont({
src: [
@@ -45,16 +45,16 @@ axios.defaults.baseURL = "http://localhost:2979";
// add negative margin for smooth transition to fill the space of the sidebar
const translate = tw`lg:-ml-64 -ml-14`;
const AutoRedirectEffect = () => {
const { isLoading, data } = useAppState();
const pathname = usePathname();
React.useEffect(() => {
if (!isLoading && !data.isJoined && pathname !== "/") {
redirect("/");
}
}, [isLoading, data, pathname]);
return <></>;
};
// const AutoRedirectEffect = () => {
// const { isLoading, data } = useAppState();
// const pathname = usePathname();
// React.useEffect(() => {
// if (!isLoading && !data.isJoined && pathname !== "/") {
// redirect("/");
// }
// }, [isLoading, data, pathname]);
// return <></>;
// };
export default function RootLayout({
children,
@@ -84,9 +84,9 @@ export default function RootLayout({
}
}, [userPrefersDarkmode, useDarkTheme, setUseDarkTheme]);
const changeThemeHandler = (target: ChangeEvent, currentValue: boolean) => {
setUseDarkTheme(currentValue);
};
// const changeThemeHandler = (target: ChangeEvent, currentValue: boolean) => {
// setUseDarkTheme(currentValue);
// };
return (
<html lang="en">
@@ -105,9 +105,7 @@ export default function RootLayout({
<AppContext.Consumer>
{(appState) => {
const showSidebarDerived = Boolean(
showSidebar &&
!appState.isLoading &&
appState.data.isJoined,
showSidebar && !appState.isLoading && appState.data.isJoined
);
return (
<>
@@ -149,7 +147,7 @@ export default function RootLayout({
<div className="px-1">
<div className="relative flex h-full flex-1 flex-col">
<main>
<AutoRedirectEffect />
{/* <AutoRedirectEffect /> */}
<Button
fullWidth
onClick={() => {

View File

@@ -7,6 +7,7 @@ import { QuickActions } from "@/components/dashboard/quickActions";
import { TaskQueue } from "@/components/dashboard/taskQueue";
import { useAppState } from "@/components/hooks/useAppContext";
import { MachineContextProvider } from "@/components/hooks/useMachines";
import { LoadingOverlay } from "@/components/join/loadingOverlay";
import { tw } from "@/utils/tailwind";
import JoinPrequel from "@/views/joinPrequel";
@@ -37,7 +38,20 @@ const DashboardPanel = (props: DashboardPanelProps) => {
};
export default function Dashboard() {
const { data } = useAppState();
const { data, isLoading } = useAppState();
if (isLoading) {
return (
<div className="grid h-full place-items-center">
<div className="mt-8 w-full max-w-xl">
<LoadingOverlay
title="Clan Experience"
subtitle="Loading"
variant="circle"
/>
</div>
</div>
);
}
if (!data.isJoined) {
return <JoinPrequel />;
}

View File

@@ -7,16 +7,12 @@ import {
Edit,
Group,
Key,
MenuOpen,
NetworkCell,
Settings,
SettingsEthernet,
VisibilityOff,
} from "@mui/icons-material";
import {
Avatar,
Button,
Divider,
IconButton,
List,
ListItem,
@@ -29,7 +25,7 @@ import {
Typography,
} from "@mui/material";
import { useState } from "react";
import { useListMachines } from "@/api/default/default";
// import { useListMachines } from "@/api/default/default";
export async function generateStaticParams() {
return [{ id: "1" }, { id: "2" }];
@@ -46,7 +42,7 @@ interface TemplateDetailProps {
params: { id: string };
}
export default function TemplateDetail({ params }: TemplateDetailProps) {
const { data, isLoading } = useListMachines();
// const { data, isLoading } = useListMachines();
const details = getTemplate(params);
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);

View File

@@ -2,7 +2,6 @@ import { ChevronRight } from "@mui/icons-material";
import {
Avatar,
Divider,
IconButton,
List,
ListItem,
ListItemAvatar,