Polished margin of all pages and fixed logout not clearing token

This commit is contained in:
Keannu Christian Bernasol 2023-03-06 14:28:18 +08:00
parent 48ed8f45c6
commit 18d9fbe1ef
13 changed files with 169 additions and 16 deletions

View file

@ -7,6 +7,7 @@ import { toggle_login } from "../../Features/Redux/Slices/Login/LoginSlice";
import { SetUser } from "../../Features/Redux/Slices/LoggedInUserSlice/LoggedInUserSlice";
import { useDispatch, useSelector } from "react-redux";
import { LoginState } from "../../Interfaces/Interfaces";
import { useNavigate } from "react-router-dom";
export interface props {
children: React.ReactNode;
@ -14,6 +15,7 @@ export interface props {
export default function Container(props: props) {
const dispatch = useDispatch();
const navigate = useNavigate();
const logged_in = useSelector((state: LoginState) => state.logged_in.value);
// Function to check for previous login session
async function CheckPreviousSession() {
@ -35,7 +37,15 @@ export default function Container(props: props) {
<Sidebar />
</div>
<div style={styles.route_wrapper}>
{props.children}
<div
style={{
paddingTop: 16,
paddingLeft: 16,
paddingRight: 16,
}}
>
{props.children}
</div>
<div style={{ padding: 64 }} />
</div>
</div>

View file

@ -1,5 +1,4 @@
import { useSelector, useDispatch } from "react-redux";
import { toggle_login } from "../../Features/Redux/Slices/Login/LoginSlice";
import { useSelector } from "react-redux";
import { Button } from "@mui/material";
import styles from "../../styles";
import { useNavigate } from "react-router-dom";
@ -12,12 +11,6 @@ export default function Login() {
(state: LoggedInUserState) => state.logged_in_user.value
);
const navigate = useNavigate();
const dispatch = useDispatch();
async function login() {
await dispatch(toggle_login());
await console.log("Login State Toggled " + logged_in);
}
if (logged_in) {
return (
<p style={{ ...styles.text_white, ...styles.text_M }}>

View file

@ -20,6 +20,7 @@ export default function Logout(props: props) {
async function logout() {
await dispatch(toggle_login());
localStorage.removeItem("token");
navigate("/");
}