File tree Expand file tree Collapse file tree
pecan/Frontend/pecan-live-dashboard/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,25 +4,24 @@ import Sidebar from "./components/Sidebar";
44import Hamburger from "./components/HamburgerMenu" ;
55import { Outlet } from "react-router" ;
66
7-
87function App ( ) {
98 const [ isSidebarOpen , setIsSidebarOpen ] = useState < boolean > ( false ) ;
109
1110 return (
12- < >
13- < div className = "h-screen flex flex-row " >
14- < div className = "h-screen w-[60px]" >
15- < Hamburger trigger = { ( ) => setIsSidebarOpen ( true ) } />
16- < Sidebar isOpen = { isSidebarOpen } onClose = { ( ) => setIsSidebarOpen ( false ) } />
17- </ div >
18-
19- { /* Main content area, Outlet element is needed to display the rendered child pages received from the routes */ }
20- < main id = "main-content" className = " w-100 h-full p-4" >
21- < Outlet />
22- </ main >
11+ < div className = "h-screen flex flex-row " >
12+ < div className = "h-screen w-[60px]" >
13+ < Hamburger trigger = { ( ) => setIsSidebarOpen ( true ) } />
14+ < Sidebar
15+ isOpen = { isSidebarOpen }
16+ onClose = { ( ) => setIsSidebarOpen ( false ) }
17+ />
2318 </ div >
24-
25- </ >
19+
20+ { /* Main content area, Outlet element is needed to display the rendered child pages received from the routes */ }
21+ < main id = "main-content" className = " w-100 h-full p-4" >
22+ < Outlet />
23+ </ main >
24+ </ div >
2625 ) ;
2726}
2827
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ function Sidebar({ isOpen, onClose }: Readonly<InputProps>) {
3434 < NavLink onClick = { onClose } to = { "/" } >
3535 < img className = "my-10 cursor-pointer" src = { banner } alt = "banner" />
3636 </ NavLink >
37- { /* Could create a global function to close the sidebar and use it in the component rather than passing it in every time */ }
37+ { /* Could create a global function to close the sidebar and use it in the component rather than passing onClose in every time */ }
3838 < ul className = "p-0" >
3939 < SidebarOption
4040 option = "Dashboard"
@@ -46,12 +46,17 @@ function Sidebar({ isOpen, onClose }: Readonly<InputProps>) {
4646 path = "/accumulator"
4747 onClose = { onClose }
4848 />
49+ < SidebarOption
50+ option = "Chargecart"
51+ path = "/chargecart"
52+ onClose = { onClose }
53+ />
4954 </ ul >
5055 </ div >
5156 < footer className = "font-footer flex flex-col space-y-8 mb-10" >
5257 { /* Should go to /account*/ }
5358 < NavLink
54- to = { "/" }
59+ to = { "/account " }
5560 className = "!no-underline text-md flex flex-row space-x-6 ml-4"
5661 onClick = { onClose }
5762 >
@@ -60,7 +65,7 @@ function Sidebar({ isOpen, onClose }: Readonly<InputProps>) {
6065 </ NavLink >
6166 { /* Should go to /settings*/ }
6267 < NavLink
63- to = { "/" }
68+ to = { "/settings " }
6469 className = "!no-underline flex flex-row space-x-6 text-md ml-4"
6570 onClick = { onClose }
6671 >
Original file line number Diff line number Diff line change 1+ function ChargeCart ( ) {
2+ return < div > </ div > ;
3+ }
4+
5+ export default ChargeCart ;
Original file line number Diff line number Diff line change @@ -2,14 +2,21 @@ import { createBrowserRouter } from "react-router";
22import App from "./App" ;
33import Dashboard from "./pages/Dashboard" ;
44import Accumulator from "./pages/Accumulator" ;
5+ import Account from "./pages/Account" ;
6+ import Settings from "./pages/Settings" ;
7+ import ChargeCart from "./pages/ChargeCart" ;
58
69export const router = createBrowserRouter ( [
710 {
811 path : "/" ,
912 element : < App /> ,
13+ //Pages are separate components, to add a route that is related to '/' just add a child, path is the relative path
1014 children : [
1115 { path : "dashboard" , element : < Dashboard /> } ,
1216 { path : "accumulator" , element : < Accumulator /> } ,
17+ { path : "account" , element : < Account /> } ,
18+ { path : "settings" , element : < Settings /> } ,
19+ { path : "chargecart" , element : < ChargeCart /> } ,
1320 ] ,
1421 } ,
1522] ) ;
You can’t perform that action at this time.
0 commit comments