mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2025-05-12 09:31:07 +08:00
Polished margin of all pages and fixed logout not clearing token
This commit is contained in:
parent
48ed8f45c6
commit
18d9fbe1ef
13 changed files with 169 additions and 16 deletions
|
@ -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>
|
||||
|
|
|
@ -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 }}>
|
||||
|
|
|
@ -20,6 +20,7 @@ export default function Logout(props: props) {
|
|||
|
||||
async function logout() {
|
||||
await dispatch(toggle_login());
|
||||
localStorage.removeItem("token");
|
||||
navigate("/");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue