mirror of
https://github.com/lemeow125/EquipmentTracker-Frontend.git
synced 2025-06-30 01:05:45 +08:00
Added revalidation component to restore previous user sessions
This commit is contained in:
parent
139c0a3e3c
commit
f4468d4010
4 changed files with 103 additions and 20 deletions
|
@ -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={{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue