Added basic page navigation

This commit is contained in:
Keannu Bernasol 2023-02-15 12:31:28 +08:00
parent 4dc107f224
commit 3200f9866b
3 changed files with 34 additions and 17 deletions

View file

@ -2,7 +2,6 @@ import React from "react";
import Dashboard from "./Routes/Dashboard/Dashboard";
import Error from "./Routes/Error/Error";
import Products from "./Routes/Products/Products";
import Header from "./Components/Header/Header";
import Container from "./Components/Container/Container";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import Store from "./Plugins/Redux/Store/Store";
@ -11,12 +10,30 @@ import { Provider } from "react-redux";
const router = createBrowserRouter([
{
path: "/",
element: <Dashboard />,
errorElement: <Error />,
element: (
<React.StrictMode>
<Container>
<Dashboard />
</Container>
</React.StrictMode>
),
errorElement: (
<React.StrictMode>
<Container>
<Error />
</Container>
</React.StrictMode>
),
},
{
path: "/Products",
element: <Products />,
element: (
<React.StrictMode>
<Container>
<Products />
</Container>
</React.StrictMode>
),
},
]);
@ -24,10 +41,7 @@ export default function App() {
return (
<React.StrictMode>
<Provider store={Store}>
<Header />
<Container>
<RouterProvider router={router} />
</Container>
<RouterProvider router={router} />
</Provider>
</React.StrictMode>
);

View file

@ -1,5 +1,6 @@
import React from "react";
import Sidebar from "../Sidebar/Sidebar";
import Header from "../Header/Header";
import styles from "../../styles";
export interface props {
@ -9,12 +10,11 @@ export interface props {
export default function Container(props: props) {
return (
<div>
<div>
<div style={{ width: "15%", position: "fixed" }}>
<Sidebar />
</div>
<div style={styles.route_wrapper}>{props.children}</div>
<Header />
<div style={{ width: "15%", position: "fixed" }}>
<Sidebar />
</div>
<div style={styles.route_wrapper}>{props.children}</div>
</div>
);
}

View file

@ -1,6 +1,8 @@
import React from "react";
import styles from "../../styles";
import SidebarButton from "../SidebarButton/SidebarButton";
import { redirect } from "react-router-dom";
import { useNavigate } from "react-router-dom";
export interface state {
minimized: {
value: boolean;
@ -9,12 +11,13 @@ export interface state {
};
}
export default function Sidebar() {
const navigate = useNavigate();
return (
<div style={styles.sidebar_wrapper}>
<SidebarButton onClick={() => console.log("WIP!")} name="Dashboard" />
<SidebarButton onClick={() => console.log("WIP!")} name="Products" />
<SidebarButton onClick={() => console.log("WIP!")} name="Inventory" />
<SidebarButton onClick={() => console.log("WIP!")} name="Logs" />
<SidebarButton onClick={() => navigate("/")} name="Dashboard" />
<SidebarButton onClick={() => navigate("/Products")} name="Products" />
<SidebarButton onClick={() => navigate("/Inventory")} name="Inventory" />
<SidebarButton onClick={() => navigate("/Logs")} name="Logs" />
</div>
);
}