File tree 10 files changed +24605
-24720
lines changed
10 files changed +24605
-24720
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { HomePage } from "./pages/Homepage";
4
4
import { AppContextProvider } from "./context/AppContextProvider" ;
5
5
import { Flags } from "./pages/Flags" ;
6
6
import { Segments } from "./pages/Segments" ;
7
- import { Dashboard } from "./pages/Dashboard" ;
7
+ import Dashboard from "./pages/Dashboard" ;
8
8
import PrivateRoute from "./components/shared/PrivateRoute" ;
9
9
import { NotificationProvider } from "./components/shared/NotificationProvider" ;
10
10
import { ApiKeys } from "./components/settings/apiKeys/ApiKeys" ;
@@ -16,6 +16,7 @@ const App: React.FC = () => {
16
16
< BrowserRouter >
17
17
< Routes >
18
18
< Route path = "/" element = { < HomePage /> } />
19
+
19
20
< Route
20
21
path = "/dashboard"
21
22
element = {
Original file line number Diff line number Diff line change
1
+ import { Outlet } from "react-router-dom" ;
2
+
3
+ import Sidebar from "./Sidebar" ;
4
+
5
+ const AuthLayout = ( ) => {
6
+ return (
7
+ < div className = "flex w-screen bg-[#F9FAFB]" >
8
+ < aside className = "pl-2 py-2 w-60 h-screen" >
9
+ < div className = "pl-2 pt-10 rounded-2xl bg-white h-full" >
10
+ < Sidebar />
11
+ </ div >
12
+ </ aside >
13
+ < div className = "w-[calc(100vw_-_240px)] p-6 max-w-6xl mx-auto" >
14
+ < Outlet />
15
+ </ div >
16
+ </ div >
17
+ ) ;
18
+ } ;
19
+
20
+ export default AuthLayout ;
Original file line number Diff line number Diff line change @@ -2,14 +2,15 @@ import { ReactElement } from "react";
2
2
import React from "react" ;
3
3
import { Navigate } from "react-router-dom" ;
4
4
import { useAppContext } from "../../context/AppContextProvider" ;
5
+ import DashboardLayout from "../../layout/DashboardLayout" ;
5
6
6
7
const PrivateRoute : React . FC < { children : ReactElement } > = ( { children } ) => {
7
8
const { authContext } = useAppContext ( ) ;
8
9
9
10
return ! ( authContext . userData ?. authenticated as boolean ) ? (
10
11
< Navigate replace to = { "/unauthorized" } />
11
12
) : (
12
- children
13
+ < DashboardLayout > { children } </ DashboardLayout >
13
14
) ;
14
15
} ;
15
16
Original file line number Diff line number Diff line change
1
+ import { Link , useLocation } from "react-router-dom" ;
2
+ import {
3
+ ArrowLeftOnRectangleIcon ,
4
+ Cog6ToothIcon ,
5
+ FlagIcon ,
6
+ FolderIcon ,
7
+ HomeIcon ,
8
+ } from "@heroicons/react/24/outline" ;
9
+
10
+ const Sidebar = ( ) => {
11
+ const location = useLocation ( ) ;
12
+
13
+ const routes = [
14
+ {
15
+ id : 1 ,
16
+ link : "/dashboard" ,
17
+ name : "Dashboard" ,
18
+ icon : < HomeIcon className = "h-5 w-5 font-extrabold" /> ,
19
+ } ,
20
+ {
21
+ id : 2 ,
22
+ link : "/flags" ,
23
+ name : "Flags" ,
24
+ icon : < FlagIcon className = "h-5 w-5 font-extrabold" /> ,
25
+ } ,
26
+ {
27
+ id : 3 ,
28
+ link : "/segments" ,
29
+ name : "Segments" ,
30
+ icon : < FolderIcon className = "h-5 w-5 font-extrabold" /> ,
31
+ } ,
32
+ {
33
+ id : 4 ,
34
+ link : "/settings/apikeys" ,
35
+ name : "Settings" ,
36
+ icon : < Cog6ToothIcon className = "h-5 w-5 font-extrabold" /> ,
37
+ } ,
38
+ ] ;
39
+
40
+ return (
41
+ < div className = "flex flex-col justify-between h-full" >
42
+ < ul className = "flex flex-col gap-8" >
43
+ { routes . map ( ( el ) => (
44
+ < li key = { el . id } >
45
+ < Link
46
+ to = { el . link }
47
+ className = { `flex items-center text-base gap-4 pl-8 ${
48
+ el . link === location . pathname
49
+ ? "text-black font-bold"
50
+ : "text-[#2563EB]"
51
+ } hover:text-black`}
52
+ >
53
+ { el . icon }
54
+ < span > { el . name } </ span >
55
+ </ Link >
56
+ </ li >
57
+ ) ) }
58
+ </ ul >
59
+ < div className = "bg-[#2563EB] hover:bg-blue-700 text-white py-3 rounded-b-2xl" >
60
+ < Link
61
+ to = "/"
62
+ className = "flex items-center text-base gap-4 pl-8 text-white hover:"
63
+ >
64
+ < ArrowLeftOnRectangleIcon className = "h-5 w-5 font-extrabold" />
65
+ < span > Logout</ span >
66
+ </ Link >
67
+ </ div >
68
+ </ div >
69
+ ) ;
70
+ } ;
71
+
72
+ export default Sidebar ;
You can’t perform that action at this time.
0 commit comments