App.js 1.45 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
  const isLs = localStorage.getItem('login')

  function loginDefault() {
    if (isLs === null) {
      localStorage.setItem('login', false)
    }
Spark's avatar
Spark committed
23
24
25
26
    if (isLs === false || isLs === null) {
      localStorage.setItem('local-code', '3743011')

    }
27
  }
Spark's avatar
Spark committed
28

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

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

Spark's avatar
Spark committed
47
        <OnlyUser path='/edit'>
Spark's avatar
Spark committed
48
          <EditPage />
Spark's avatar
Spark committed
49
        </OnlyUser>
Spark's avatar
Spark committed
50
51
52

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

Spark's avatar
Spark committed
54
      <Footer />
Spark's avatar
layout    
Spark committed
55
    </Router>
Spark's avatar
Spark committed
56

Spark's avatar
layout    
Spark committed
57
58
59
60
  );
}

export default App;