-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
58 lines (46 loc) · 1.4 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
import {BrowserRouter as Router, Routes, Route} from 'react-router-dom';
import OneMovie from './components/OneMovie';
import Home from './pages/Home';
import Login from './pages/Login';
import Movies from './pages/Movies';
import Search from './pages/Search';
import SingUp from './pages/SignUp';
import UserAccount from './pages/UserAccount';
import {useGloablData} from "./context/GlobalData";
function App() {
const [{current_token}, ] = useGloablData();
// some routes are protected
return (
<Router>
<Routes>
<Route path='/' element={<Home />} />
<Route path="/watch"
element={
current_token === undefined || current_token === null
? <Login />
: <Movies />
}
/>
<Route path="/search" element={
current_token === undefined || current_token === null
? <Login />
: <Search />
}
/>
<Route path="/one" element={
current_token === undefined || current_token === null
? <Login />
: <OneMovie />}
/>
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<SingUp />} />
<Route path="/account" element={
current_token === undefined || current_token === null
? <Login />
: <UserAccount />}
/>
</Routes>
</Router>
);
}
export default App;