Added revalidation component to restore previous user sessions

This commit is contained in:
Keannu Christian Bernasol 2023-11-19 16:46:04 +08:00
parent 139c0a3e3c
commit f4468d4010
4 changed files with 103 additions and 20 deletions

View file

@ -1,28 +1,14 @@
import { useEffect, useState } from "react";
import { useState } from "react";
import styles, { colors } from "../../styles";
import MenuIcon from "@mui/icons-material/Menu";
import SidebarModal from "../SidebarModal/SidebarModal";
import { Drawer } from "@mui/material";
import { useSelector } from "react-redux";
import { RootState } from "../Plugins/Redux/Store/Store";
import { useNavigate } from "react-router-dom";
export interface props {
label: string;
}
export default function Header(props: props) {
const [SidebarOpen, SetSidebarOpen] = useState(false);
const authenticated = useSelector((state: RootState) => state.auth.value);
const navigate = useNavigate();
useEffect(() => {
if (!authenticated) {
navigate("/");
console.log("Not logged in. Redirecting to landing page");
}
}, [authenticated, navigate]);
return (
<div
style={{