From 1f668be499bd3a7d745541e61a476a9e3abb6600 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Mon, 6 Mar 2023 00:56:21 +0800 Subject: [PATCH] Added initial login logic --- src/App.tsx | 9 ++ src/Components/Icons/LoginIcon/LoginIcon.tsx | 24 ++++++ src/Components/Login/Login.tsx | 8 +- src/Components/Logout/Logout.tsx | 4 +- src/Features/Login/LoginSlice.tsx | 4 +- src/Routes/Login/Login.tsx | 87 +++++++++++++++++++- src/styles.tsx | 8 ++ 7 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 src/Components/Icons/LoginIcon/LoginIcon.tsx diff --git a/src/App.tsx b/src/App.tsx index 1faf3a6..414c525 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,6 +8,7 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom"; import Store from "./Plugins/Redux/Store/Store"; import { Provider } from "react-redux"; import Inventory from "./Routes/Inventory/Inventory"; +import Login from "./Routes/Login/Login"; const router = createBrowserRouter([ { @@ -47,6 +48,14 @@ const router = createBrowserRouter([ ), }, + { + path: "/Login", + element: ( + + + + ), + }, ]); export default function App() { diff --git a/src/Components/Icons/LoginIcon/LoginIcon.tsx b/src/Components/Icons/LoginIcon/LoginIcon.tsx new file mode 100644 index 0000000..1e0b264 --- /dev/null +++ b/src/Components/Icons/LoginIcon/LoginIcon.tsx @@ -0,0 +1,24 @@ +import React from "react"; + +export interface props { + size: number; + color: string; +} +export default function LoginIcon(props: props) { + return ( + + + + + + ); +} diff --git a/src/Components/Login/Login.tsx b/src/Components/Login/Login.tsx index 3e8e11f..4a33838 100644 --- a/src/Components/Login/Login.tsx +++ b/src/Components/Login/Login.tsx @@ -1,7 +1,8 @@ import { useSelector, useDispatch } from "react-redux"; -import { toggle } from "../../Features/Login/LoginSlice"; +import { toggle_login } from "../../Features/Login/LoginSlice"; import { Button } from "@mui/material"; import styles from "../../styles"; +import { useNavigate } from "react-router-dom"; export interface state { logged_in: { @@ -10,9 +11,10 @@ export interface state { } export default function Login() { const logged_in = useSelector((state: state) => state.logged_in.value); + const navigate = useNavigate(); const dispatch = useDispatch(); async function login() { - await dispatch(toggle()); + await dispatch(toggle_login()); await console.log("Login State Toggled " + logged_in); } @@ -24,7 +26,7 @@ export default function Login() { return (
+
); diff --git a/src/styles.tsx b/src/styles.tsx index 97a4b5b..5331d0e 100644 --- a/src/styles.tsx +++ b/src/styles.tsx @@ -94,6 +94,14 @@ const styles: { [key: string]: React.CSSProperties } = { borderRadius: 16, gap: 4, }, + button_baseline: { + width: "8rem", + height: 32, + border: "none", + padding: 8, + borderRadius: 16, + margin: 4, + }, logout_button: { backgroundColor: "#0b2322", width: "30vh",