App.js 1.35 KB
Newer Older
1
import React from 'react';
Spark's avatar
Spark committed
2
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
Spark's avatar
layout    
Spark committed
3
4
import './App.css';
import Home from './pages/Home';
Spark's avatar
Spark committed
5
import SignupPage from './pages/SignupPage';
Spark's avatar
Spark committed
6
import LoginPage from './pages/LoginPage';
Spark's avatar
Spark committed
7
import EditPage from './pages/EditPage';
Spark's avatar
Spark committed
8
import OnlyUser from './utils/OnlyUser';
Spark's avatar
Spark committed
9
import PageNotFound from './components/PageNotFound';
Spark's avatar
Spark committed
10
import Footer from './components/Footer';
11
import GetLocFirst from './pages/GetLocFirst';
Spark's avatar
Spark committed
12
import { isLogined } from './utils/Auth';
Spark's avatar
layout    
Spark committed
13
14
15


function App() {
Spark's avatar
Spark committed
16

17
18
19
20
21
22
23
  const isLs = localStorage.getItem('login')

  function loginDefault() {
    if (isLs === null) {
      localStorage.setItem('login', false)
    }
  }
Spark's avatar
Spark committed
24

Spark's avatar
layout    
Spark committed
25
26
  return (
    <Router>
27
      {loginDefault()}
Spark's avatar
Spark committed
28
      <Switch>
Spark's avatar
Spark committed
29
        <Route exact path='/' component={Home} />
Spark's avatar
Spark committed
30
31
32
33
34
35
36
37
38
39
40
        {isLogined() ?
          <Route path='/signup' component={PageNotFound} />
          :
          <Route path='/signup' component={SignupPage} />
        }

        {isLogined() ?
          <Route path='/login' component={PageNotFound} />
          :
          <Route path='/login' component={LoginPage} />
        }
41
        <Route path='/first-local-code' component={GetLocFirst} />
42

Spark's avatar
Spark committed
43
        <OnlyUser path='/edit'>
Spark's avatar
Spark committed
44
          <EditPage />
Spark's avatar
Spark committed
45
        </OnlyUser>
Spark's avatar
Spark committed
46
47
48

        <Route component={PageNotFound} />
      </Switch>
Spark's avatar
Spark committed
49

Spark's avatar
Spark committed
50
      <Footer />
Spark's avatar
layout    
Spark committed
51
    </Router>
Spark's avatar
Spark committed
52

Spark's avatar
layout    
Spark committed
53
54
55
56
  );
}

export default App;