Skip to content

Commit

Permalink
fix auth route problem
Browse files Browse the repository at this point in the history
  • Loading branch information
KhalilMeziane committed Jan 6, 2022
1 parent 46b4318 commit 4d53a78
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ function App() {
</ChakraProvider>
);
}

export default App;
export default App;
6 changes: 1 addition & 5 deletions src/pages/home.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React, { useState } from 'react'
import React from 'react'
// import { Link } from 'react-router-dom'
import { Helmet } from 'react-helmet'
import { Navbar, Header } from '../components/_index'
import { Box } from '@chakra-ui/react'
import headerImage from '../assets/images/header2.jpg'




export default function Home() {
const [counter,setCounter]= useState(0)
return (
<>
<Helmet>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import { AuthNavbar } from '../components/_index'
import { Box, Text, Divider, Tabs, Tab, TabPanels, TabPanel, TabList, Flex } from '@chakra-ui/react'
import { EditProject } from '../components/modals/_index'
import Pert from '../components/charts/pert/pert'
import { useParams } from 'react-router-dom'

export default function Project() {
const { id } = useParams()
console.log('id: ', id)

return (
<>
<Helmet>
Expand Down
12 changes: 6 additions & 6 deletions src/routes/_RouterConfig.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react'
import { Route, Routes } from 'react-router-dom'
import { Route, Routes, Navigate } from 'react-router-dom'
import { Home, Login, SignUp, NotFound, Profile, Dashboard, Project } from '../pages/_index'


export default function RouterConfig() {
const isAuth = localStorage.getItem('APP_TOKEN')? true:false

return (
<Routes>
<Route path="/" element={<Home/>}/>
<Route path="/login" element={<Login/>}/>
<Route path="/signup" element={<SignUp/>}/>
<Route path="/profile" element={<Profile/>}/>
<Route path="/dashboard" element={<Dashboard/>}/>
<Route path="/dashboard/:id" element={<Project/>}/>

<Route path="/profile" element={isAuth? <Profile/>:<Navigate to="/login"/>}/>
<Route path="/dashboard" element={isAuth? <Dashboard/>:<Navigate to="/login"/>}/>
<Route path="/dashboard/:id" element={isAuth? <Project/>:<Navigate to="/login"/>}/>
<Route path="*" element={<NotFound/>}/>
</Routes>
)
Expand Down

0 comments on commit 4d53a78

Please sign in to comment.