mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2024-11-17 06:39:25 +08:00
Restrict all pages to only logged in users
This commit is contained in:
parent
18d9fbe1ef
commit
9cdca33783
6 changed files with 40 additions and 2 deletions
|
@ -45,13 +45,15 @@ export default function Sidebar() {
|
||||||
>
|
>
|
||||||
<ProductsIcon size={48} color="white" />
|
<ProductsIcon size={48} color="white" />
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
|
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
onClick={() => navigate("/Inventory")}
|
onClick={() => navigate("/Inventory")}
|
||||||
name="Inventory"
|
name="Inventory"
|
||||||
>
|
>
|
||||||
<InventoryIcon size={48} color="white" />
|
<InventoryIcon size={48} color="white" />
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
|
<SidebarButton onClick={() => navigate("/Logs")} name="Logs">
|
||||||
|
<LogsIcon size={48} color="white" />
|
||||||
|
</SidebarButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,8 +8,16 @@ import styles from "../../styles";
|
||||||
import HomeIcon from "../../Components/Icons/HomeIcon/HomeIcon";
|
import HomeIcon from "../../Components/Icons/HomeIcon/HomeIcon";
|
||||||
import ColoredCube from "../../Components/ColoredCube/ColoredCube";
|
import ColoredCube from "../../Components/ColoredCube/ColoredCube";
|
||||||
import RecentlyAddedIcon from "../../Components/Icons/RecentlyAddedIcon/RecentlyAddedIcon";
|
import RecentlyAddedIcon from "../../Components/Icons/RecentlyAddedIcon/RecentlyAddedIcon";
|
||||||
|
import { Navigate } from "react-router-dom";
|
||||||
|
import { LoginState } from "../../Interfaces/Interfaces";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
|
const logged_in = useSelector((state: LoginState) => state.logged_in.value);
|
||||||
|
if (!logged_in) {
|
||||||
|
return <Navigate to="/Login" replace />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div style={styles.flex_row}>
|
<div style={styles.flex_row}>
|
||||||
|
|
|
@ -10,8 +10,15 @@ import {
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { SampleLogData } from "../../Components/SampleData/SampleData";
|
import { SampleLogData } from "../../Components/SampleData/SampleData";
|
||||||
|
import { Navigate } from "react-router-dom";
|
||||||
|
import { LoginState } from "../../Interfaces/Interfaces";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
export default function Logs() {
|
export default function Logs() {
|
||||||
|
const logged_in = useSelector((state: LoginState) => state.logged_in.value);
|
||||||
|
if (!logged_in) {
|
||||||
|
return <Navigate to="/Login" replace />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div style={styles.flex_row}>
|
<div style={styles.flex_row}>
|
||||||
|
|
|
@ -2,9 +2,16 @@ import * as React from "react";
|
||||||
import styles from "../../styles";
|
import styles from "../../styles";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
import { Navigate } from "react-router-dom";
|
||||||
|
import { LoginState } from "../../Interfaces/Interfaces";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
export default function Product() {
|
export default function Product() {
|
||||||
let { id } = useParams();
|
let { id } = useParams();
|
||||||
|
const logged_in = useSelector((state: LoginState) => state.logged_in.value);
|
||||||
|
if (!logged_in) {
|
||||||
|
return <Navigate to="/Login" replace />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1 style={{ ...styles.text_white, ...styles.text_XL }}>
|
<h1 style={{ ...styles.text_white, ...styles.text_XL }}>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import styles from "../../styles";
|
import styles from "../../styles";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import ProductsIcon from "../../Components/Icons/ProductsIcon/ProductsIcon";
|
import ProductsIcon from "../../Components/Icons/ProductsIcon/ProductsIcon";
|
||||||
|
@ -6,9 +6,16 @@ import AddIcon from "../../Components/Icons/AddIcon/AddIcon";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import { SampleProducts } from "../../Components/SampleData/SampleData";
|
import { SampleProducts } from "../../Components/SampleData/SampleData";
|
||||||
import ViewManager from "../../Components/ProductsPage/ViewManager";
|
import ViewManager from "../../Components/ProductsPage/ViewManager";
|
||||||
|
import { Navigate } from "react-router-dom";
|
||||||
|
import { LoginState } from "../../Interfaces/Interfaces";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
export default function Products() {
|
export default function Products() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const logged_in = useSelector((state: LoginState) => state.logged_in.value);
|
||||||
|
if (!logged_in) {
|
||||||
|
return <Navigate to="/Login" replace />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div style={styles.content_row}>
|
<div style={styles.content_row}>
|
||||||
|
|
|
@ -11,8 +11,15 @@ import {
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { SampleInventoryData } from "../../Components/SampleData/SampleData";
|
import { SampleInventoryData } from "../../Components/SampleData/SampleData";
|
||||||
import StockRenderer from "../../Components/InventoryPage/StockRenderer/StockRenderer";
|
import StockRenderer from "../../Components/InventoryPage/StockRenderer/StockRenderer";
|
||||||
|
import { Navigate } from "react-router-dom";
|
||||||
|
import { LoginState } from "../../Interfaces/Interfaces";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
export default function Inventory() {
|
export default function Inventory() {
|
||||||
|
const logged_in = useSelector((state: LoginState) => state.logged_in.value);
|
||||||
|
if (!logged_in) {
|
||||||
|
return <Navigate to="/Login" replace />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div style={{ height: "100%" }}>
|
<div style={{ height: "100%" }}>
|
||||||
<div style={styles.content_row}>
|
<div style={styles.content_row}>
|
||||||
|
|
Loading…
Reference in a new issue