-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
62 lines (54 loc) · 2.31 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//import all the pages that will need to be routed to
import Home from './pages/Home';
import About from './pages/About'
import Dashboard from './pages/Dashboard';
import CreateAsset from './pages/CreateAsset';
import CreateTask from './pages/CreateTask';
import NoAccess from './pages/NoAccess';
import Asset from './pages/Asset';
import Settings from './pages/Settings'
import Profile from './pages/Profile'
import Intermediaries from './pages/Intermediaries'
import AddNote from './pages/AddNote'
// import the react-router-dom hooks to handle the routing
import { BrowserRouter as Router, Route,Routes } from 'react-router-dom'
import { useMoralis } from "react-moralis";
// this is the main application page (when ignoring index.js)
//this page allows for routing to different pages using react-router-dom
function App() {
// The useMoralis hook provides all the basics functionalities that is needed for authentication and user data.
const { isAuthenticated } = useMoralis();
return (
<Router>
<>
<Routes>
<Route path= '/' element = {<Home/>}/>
<Route path= '/about' element={<About />} />
{/* for access priviledge, if user is logged in they can access dashboard and on,
if not it takes them to no access page */}
{isAuthenticated ?
<>
<Route path= '/dashboard' element={<Dashboard />} />
<Route path= '/createAsset' element={<CreateAsset />} />
<Route path= '/createTask/:id' element={<CreateTask />} />
<Route path= '/asset/:id' element={<Asset/>} />
<Route path= '/profile/:value' element={<Profile/>} />
<Route path= '/taskNote/:id' element={<AddNote/>} />
<Route path= '/intermediaries' element={<Intermediaries/>} />
</>
:
<>
<Route path= '/dashboard' element={<NoAccess />} />
<Route path= '/createAsset' element={<NoAccess />} />
<Route path= '/createTask/:id' element={<NoAccess />} />
<Route path= '/asset/:id' element={<NoAccess/>} />
<Route path= '/profile/:value' element={<NoAccess/>} />
<Route path= '/taskNote/:id' element={<NoAccess/>} />
<Route path= '/intermediaries' element={<NoAccess/>} />
</>}
</Routes>
</>
</Router>
);
}
export default App;