Skip to content

Commit 347f591

Browse files
committed
Flatten Modules
1 parent 10505ad commit 347f591

File tree

144 files changed

+142
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+142
-163
lines changed
File renamed without changes.
File renamed without changes.

src/App.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,11 @@ import { ThemeProvider } from '@material-ui/styles'
44

55
import CssBaseline from '@material-ui/core/CssBaseline'
66

7-
import config from './config'
8-
import authService from './_services/authService'
9-
10-
import api from './_api'
11-
12-
import store from './_store'
7+
import store from './_state'
138
import theme from './_theme'
149

1510
import AppRouter from './AppRouter'
1611

17-
// Init the API service
18-
authService.init({
19-
useSampleData: config.useSampleData,
20-
})
21-
22-
// Init rest API client
23-
api.init({
24-
useSampleData: config.useSampleData,
25-
})
26-
2712
const App: React.FC = () => {
2813
return (
2914
<div className="App">

src/AppDocs.md

Lines changed: 22 additions & 0 deletions

src/AppRouter.tsx

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,56 @@
1-
import React from 'react'
2-
import { HashRouter, BrowserRouter, Route, RouteProps, Redirect } from 'react-router-dom' //
1+
import React, { useEffect } from 'react'
2+
import {
3+
HashRouter,
4+
BrowserRouter,
5+
Route,
6+
RouteProps,
7+
Redirect,
8+
Switch,
9+
} from 'react-router-dom' //
10+
import LinearProgress from '@material-ui/core/LinearProgress'
311

4-
import config from './config'
12+
import config from './_config'
513
import authService from './_services/authService'
14+
import { useAppState, useAppEffects } from './_state/appState'
615

16+
// Import application modules
17+
import Sales from './Sales'
18+
import Content from './Content'
19+
import Admin from './Administration'
20+
21+
// Import core modules
722
import Auth from './Auth/Auth'
8-
import { DashboardContainer } from './Dashboard'
23+
import Profile from './Profile'
24+
import Organization from './Organization'
25+
import NotFound from './Misc/NotFound'
26+
27+
// Theme demo module
28+
import Demo from './Demo'
29+
30+
const LoggedInRouter = () => {
31+
const { loading, error } = useAppState()
32+
const effects = useAppEffects()
33+
34+
useEffect(() => {
35+
effects.request()
36+
}, [effects])
37+
38+
if (loading) return <LinearProgress />
39+
if (error) return <p>Error :(</p>
40+
41+
return (
42+
<Switch>
43+
<Route exact path="/" render={() => <Redirect to="/sales/dashboard" />} />
44+
<Route path={`/sales`} component={Sales} />
45+
<Route path={`/content`} component={Content} />
46+
<Route path={`/admin`} component={Admin} />
47+
<Route path={`/profile`} component={Profile} />
48+
<Route path={`/account`} component={Organization} />
49+
<Route path={`/demo`} component={Demo} />
50+
<Route component={NotFound} />
51+
</Switch>
52+
)
53+
}
954

1055
// Use different router type depending on configuration
1156
const AppRouterComponent: React.ComponentType<any> =
@@ -14,7 +59,7 @@ const AppRouterComponent: React.ComponentType<any> =
1459
const AppRouter: React.FC = () => (
1560
<AppRouterComponent>
1661
<Route path="/auth" component={Auth} />
17-
<PrivateRoute path="/" component={DashboardContainer} />
62+
<PrivateRoute path="/" component={LoggedInRouter} />
1863
</AppRouterComponent>
1964
)
2065

0 commit comments

Comments
 (0)