-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
100 lines (83 loc) · 2.45 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import PropTypes from 'prop-types'
import React from "react"
import { Switch, BrowserRouter as Router } from "react-router-dom"
import { connect } from "react-redux"
// Import Routes all
import { authProtectedRoutes, publicRoutes } from "./routes"
// Import all middleware
import Authmiddleware from "./routes/route"
// layouts Format
import VerticalLayout from "./components/VerticalLayout/"
import HorizontalLayout from "./components/HorizontalLayout/"
import NonAuthLayout from "./components/NonAuthLayout"
// Import scss
import "./assets/scss/theme.scss"
// Import Firebase Configuration file
// import { initFirebaseBackend } from "./helpers/firebase_helper"
import fakeBackend from "./helpers/AuthType/fakeBackend"
// Activating fake backend
fakeBackend()
// const firebaseConfig = {
// apiKey: process.env.REACT_APP_APIKEY,
// authDomain: process.env.REACT_APP_AUTHDOMAIN,
// databaseURL: process.env.REACT_APP_DATABASEURL,
// projectId: process.env.REACT_APP_PROJECTID,
// storageBucket: process.env.REACT_APP_STORAGEBUCKET,
// messagingSenderId: process.env.REACT_APP_MESSAGINGSENDERID,
// appId: process.env.REACT_APP_APPID,
// measurementId: process.env.REACT_APP_MEASUREMENTID,
// }
// init firebase backend
// initFirebaseBackend(firebaseConfig)
const App = props => {
function getLayout() {
let layoutCls = VerticalLayout
switch (props.layout.layoutType) {
case "horizontal":
layoutCls = HorizontalLayout
break
default:
layoutCls = VerticalLayout
break
}
return layoutCls
}
const Layout = getLayout()
return (
<React.Fragment>
<Router>
<Switch>
{publicRoutes.map((route, idx) => (
<Authmiddleware
path={route.path}
layout={NonAuthLayout}
component={route.component}
key={idx}
isAuthProtected={false}
exact
/>
))}
{authProtectedRoutes.map((route, idx) => (
<Authmiddleware
path={route.path}
layout={Layout}
component={route.component}
key={idx}
isAuthProtected={true}
exact
/>
))}
</Switch>
</Router>
</React.Fragment>
)
}
App.propTypes = {
layout: PropTypes.any
}
const mapStateToProps = state => {
return {
layout: state.Layout,
}
}
export default connect(mapStateToProps, null)(App)