From 7007a1660f0acc87be2bcb4a5935a7822316da5b Mon Sep 17 00:00:00 2001 From: LinuzJ Date: Sat, 11 Nov 2023 22:47:44 +0200 Subject: [PATCH] leaderboard and fucking shit prolly works idk --- dance-app/src/App.tsx | 5 +- dance-app/src/components/Drawer.tsx | 36 ++---- dance-app/src/components/LoginForm.tsx | 3 - dance-app/src/context/PageContext.tsx | 5 +- dance-app/src/layouts/MainDrawerLayout.tsx | 6 +- dance-app/src/sections/landing.tsx | 122 +++++++++++---------- dance-app/src/sections/login.tsx | 2 +- 7 files changed, 86 insertions(+), 93 deletions(-) diff --git a/dance-app/src/App.tsx b/dance-app/src/App.tsx index 73b92f6..ed88b05 100644 --- a/dance-app/src/App.tsx +++ b/dance-app/src/App.tsx @@ -7,6 +7,7 @@ import { ThemeProvider } from "@emotion/react"; import { Box, createTheme, CssBaseline } from "@mui/material"; import Login from "./sections/login"; import LandingPage from "./sections/landing"; +import MainDrawerLayout from "./layouts/MainDrawerLayout"; const theme = createTheme({ typography: { @@ -56,7 +57,9 @@ function App() { }} > {auth.token !== "" ? ( - + + + ) : ( )} diff --git a/dance-app/src/components/Drawer.tsx b/dance-app/src/components/Drawer.tsx index 0f7c235..ad433e5 100644 --- a/dance-app/src/components/Drawer.tsx +++ b/dance-app/src/components/Drawer.tsx @@ -1,10 +1,12 @@ import { Box, Button, useTheme } from "@mui/material"; -import { FC, useState } from "react"; +import { FC } from "react"; import "../Drawer.css"; import { makeStyles } from "@mui/styles"; +import { Pages } from "../context/PageContext"; interface DrawerProps { - onSwitch: () => void; + view: Pages; + setView: (view: Pages) => void; } const useStyles = makeStyles(() => ({ @@ -27,44 +29,30 @@ const useStyles = makeStyles(() => ({ }, })); -const MenuItems = { - Home: "Home", - Leaderboard: "Leaderboard", -} as const; - -const Drawer: FC = ({ onSwitch }) => { - const [selected, setSelected] = useState( - MenuItems.Home, - ); +const Drawer: FC = ({ view, setView }) => { const theme = useTheme(); const classes = useStyles(theme); - const toggle = (item: keyof typeof MenuItems) => { - onSwitch(); - setSelected(item); + const toggle = (item: Pages) => { + setView(item); }; return (
-
diff --git a/dance-app/src/components/LoginForm.tsx b/dance-app/src/components/LoginForm.tsx index a03cd66..4687816 100644 --- a/dance-app/src/components/LoginForm.tsx +++ b/dance-app/src/components/LoginForm.tsx @@ -41,9 +41,6 @@ const LoginForm = ({ setAuth, pb }: LoginProps) => { const handleSubmit = async (e: FormEvent) => { e.preventDefault(); - // Perform login logic here, e.g., send data to the server - console.log("Username:", username); - console.log("Password:", password); const authData = await pb .collection("users") diff --git a/dance-app/src/context/PageContext.tsx b/dance-app/src/context/PageContext.tsx index 420a4f4..912d32b 100644 --- a/dance-app/src/context/PageContext.tsx +++ b/dance-app/src/context/PageContext.tsx @@ -1,5 +1,6 @@ import { createContext } from "react"; -export const defaultPageContext = "home"; +export type Pages = "home" | "leaderboard"; +export const defaultPageContext: Pages = "home"; -export const PageContext = createContext(defaultPageContext); +export const PageContext = createContext(defaultPageContext); diff --git a/dance-app/src/layouts/MainDrawerLayout.tsx b/dance-app/src/layouts/MainDrawerLayout.tsx index d2a8251..a6e2efd 100644 --- a/dance-app/src/layouts/MainDrawerLayout.tsx +++ b/dance-app/src/layouts/MainDrawerLayout.tsx @@ -1,4 +1,3 @@ -import { CssBaseline } from "@mui/material"; import { makeStyles } from "@mui/styles"; import Drawer from "../components/Drawer"; import { useState } from "react"; @@ -29,13 +28,10 @@ const useStyles = makeStyles(() => ({ const MainDrawerLayout = ({ children }: MainDrawerLayoutProps) => { const [view, setView] = useState<"home" | "leaderboard">(defaultPageContext); const classes = useStyles(); - return (
- setView(view === "home" ? "leaderboard" : "home")} - /> +
{children}
diff --git a/dance-app/src/sections/landing.tsx b/dance-app/src/sections/landing.tsx index 762bdb2..9ae997e 100644 --- a/dance-app/src/sections/landing.tsx +++ b/dance-app/src/sections/landing.tsx @@ -1,8 +1,9 @@ -import { useEffect, useState } from "react"; +import { useContext, useEffect, useState } from "react"; import { Container, Typography, Button, Grid } from "@mui/material"; import PocketBase from "pocketbase"; -import MainDrawerLayout from "../layouts/MainDrawerLayout"; import RecordingPage from "./recording"; +import { PageContext } from "../context/PageContext"; +import Leaderboard from "../components/Leaderboard"; // interface LandingProps { // pb: PocketBase; @@ -26,6 +27,7 @@ enum Tier { const pb = new PocketBase("https://junctionb.nyman.dev"); const LandingPage = () => { + const page = useContext(PageContext); const [selectedTier, setSelectedTier] = useState(null); const [refVideos, setRefVideos] = useState([]); @@ -44,64 +46,70 @@ const LandingPage = () => { }; return ( - - {selectedTier ? ( - video.tier === selectedTier.toString(), + <> + {page === "home" ? ( + <> + {selectedTier ? ( + video.tier === selectedTier.toString(), + )} + /> + ) : ( + + + + + Ur fat! + + + Explore our amazing features! + + + + + + + + + + + + + )} - /> + ) : ( - - - - - Ur fat! - - - Explore our amazing features! - - - - - - - - - - - - - + )} - + ); }; diff --git a/dance-app/src/sections/login.tsx b/dance-app/src/sections/login.tsx index 105332a..7102b0e 100644 --- a/dance-app/src/sections/login.tsx +++ b/dance-app/src/sections/login.tsx @@ -1,4 +1,4 @@ -import { Container, Box, CssBaseline } from "@mui/material"; +import { Container, Box } from "@mui/material"; import LoginForm from "../components/LoginForm"; import PocketBase, { RecordAuthResponse, RecordModel } from "pocketbase"; import Logo from "../components/logo";