diff --git a/packages/concordia-app/package.json b/packages/concordia-app/package.json index cb5150e..14145df 100644 --- a/packages/concordia-app/package.json +++ b/packages/concordia-app/package.json @@ -28,7 +28,6 @@ "@ezerous/drizzle": "~0.4.0", "@reduxjs/toolkit": "~1.4.0", "concordia-contracts": "~0.1.0", - "history": "^5.0.0", "i18next": "^19.8.3", "i18next-browser-languagedetector": "^6.0.1", "i18next-http-backend": "^1.0.21", diff --git a/packages/concordia-app/src/App.jsx b/packages/concordia-app/src/App.jsx new file mode 100644 index 0000000..be5c160 --- /dev/null +++ b/packages/concordia-app/src/App.jsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Provider } from 'react-redux'; +import { BrowserRouter as Router } from 'react-router-dom'; +import PropTypes from 'prop-types'; +import LoadingContainer from './components/LoadingContainer'; +import Routes from './Routes'; + +// CSS +import './assets/css/app.css'; + +const App = ({ store }) => ( + + + + + + + +); + +App.propTypes = { + store: PropTypes.object.isRequired, +}; + +export default App; diff --git a/packages/concordia-app/src/Routes.jsx b/packages/concordia-app/src/Routes.jsx new file mode 100644 index 0000000..cc8f38c --- /dev/null +++ b/packages/concordia-app/src/Routes.jsx @@ -0,0 +1,59 @@ +import React, { Fragment, lazy, Suspense } from 'react'; +import { Redirect, Route, Switch } from 'react-router-dom'; +import CoreLayoutContainer from './layout/CoreLayoutContainer'; +import LoadingScreen from './components/LoadingScreen'; + +const routesConfig = [ + { + exact: true, + path: '/404', + component: lazy(() => import('./components/NotFound')), + }, + { + path: '*', + layout: CoreLayoutContainer, + routes: [ + { + exact: true, + path: '/', + component: lazy(() => import('./components/HomeContainer')), + }, + { + component: () => , + }, + ], + }, +]; + +const renderRoutes = (routes) => (routes ? ( + }> + + {routes.map((route, i) => { + const Layout = route.layout || Fragment; + const Component = route.component; + + const key = route.path ? route.path.concat(i) : ''.concat(i); + return ( + ( + + {route.routes + ? renderRoutes(route.routes) + : } + + )} + /> + ); + })} + + +) : null); + +function Routes() { + return renderRoutes(routesConfig); +} + +export default Routes; diff --git a/packages/concordia-app/src/components/App.jsx b/packages/concordia-app/src/components/App.jsx deleted file mode 100644 index 88704c8..0000000 --- a/packages/concordia-app/src/components/App.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import { Provider } from 'react-redux'; -import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; -import PropTypes from 'prop-types'; -import LoadingContainer from './LoadingContainer'; - -// CSS -import '../assets/css/app.css'; - -import CoreLayoutContainer from './CoreLayoutContainer'; -import HomeContainer from './HomeContainer'; -import NotFound from './NotFound'; - -const App = ({ store }) => ( - - - - - - - - - - - - -); - -App.propTypes = { - store: PropTypes.object.isRequired, -}; - -export default App; diff --git a/packages/concordia-app/src/components/LoadingScreen.jsx b/packages/concordia-app/src/components/LoadingScreen.jsx new file mode 100644 index 0000000..da719f1 --- /dev/null +++ b/packages/concordia-app/src/components/LoadingScreen.jsx @@ -0,0 +1,9 @@ +import React from 'react'; + +const LoadingScreen = () => ( +
+ Loading +
+); + +export default LoadingScreen; diff --git a/packages/concordia-app/src/index.jsx b/packages/concordia-app/src/index.jsx index 774b9bf..862c238 100644 --- a/packages/concordia-app/src/index.jsx +++ b/packages/concordia-app/src/index.jsx @@ -1,25 +1,25 @@ -import React from 'react'; +import React, { Suspense } from 'react'; import { render } from 'react-dom'; import { Drizzle } from '@ezerous/drizzle'; import { Breeze } from '@ezerous/breeze'; -import App from './components/App'; +import App from './App'; import store from './redux/store'; - import AppContext from './components/AppContext'; - import drizzleOptions from './options/drizzleOptions'; +import breezeOptions from './options/breezeOptions'; import * as serviceWorker from './utils/serviceWorker'; - import './assets/css/index.css'; -import breezeOptions from './options/breezeOptions'; +import LoadingScreen from './components/LoadingScreen'; const drizzle = new Drizzle(drizzleOptions, store); const breeze = new Breeze(breezeOptions, store); render( - - - , + }> + + + + , document.getElementById('root'), ); diff --git a/packages/concordia-app/src/components/CoreLayoutContainer.jsx b/packages/concordia-app/src/layout/CoreLayoutContainer.jsx similarity index 84% rename from packages/concordia-app/src/components/CoreLayoutContainer.jsx rename to packages/concordia-app/src/layout/CoreLayoutContainer.jsx index 5da971e..a248dc0 100644 --- a/packages/concordia-app/src/components/CoreLayoutContainer.jsx +++ b/packages/concordia-app/src/layout/CoreLayoutContainer.jsx @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -import MenuComponent from './MenuComponent'; +import MenuComponent from '../components/MenuComponent'; const CoreLayout = (props) => { const { children } = props;