refactor: AppContext and App entrypoints
This commit is contained in:
parent
442e7cd8d9
commit
dd0abc8a8b
7 changed files with 32 additions and 10 deletions
|
|
@ -2,3 +2,4 @@ SKIP_PREFLIGHT_CHECK=true
|
||||||
HTTPS=true
|
HTTPS=true
|
||||||
REACT_APP_TYPE_CHECK_SANCTUARY=false
|
REACT_APP_TYPE_CHECK_SANCTUARY=false
|
||||||
PORT=3001
|
PORT=3001
|
||||||
|
REACT_APP_BUILD_TARGET=LAMASSU
|
||||||
|
|
@ -88,7 +88,9 @@
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"storybook": "start-storybook -p 9009 -s public",
|
"storybook": "start-storybook -p 9009 -s public",
|
||||||
"postinstall": "patch-package",
|
"postinstall": "patch-package",
|
||||||
"build-storybook": "build-storybook -s public"
|
"build-storybook": "build-storybook -s public",
|
||||||
|
"start-lamassu": "REACT_APP_BUILD_TARGET=LAMASSU react-scripts start",
|
||||||
|
"start-pazuz": "REACT_APP_BUILD_TARGET=PAZUZ react-scripts start"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,14 @@ import {
|
||||||
} from '@material-ui/core/styles'
|
} from '@material-ui/core/styles'
|
||||||
import { create } from 'jss'
|
import { create } from 'jss'
|
||||||
import extendJss from 'jss-plugin-extend'
|
import extendJss from 'jss-plugin-extend'
|
||||||
import React, { createContext, useContext, useState } from 'react'
|
import React, { useContext, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
useLocation,
|
useLocation,
|
||||||
useHistory,
|
useHistory,
|
||||||
BrowserRouter as Router
|
BrowserRouter as Router
|
||||||
} from 'react-router-dom'
|
} from 'react-router-dom'
|
||||||
|
|
||||||
|
import AppContext from 'src/AppContext'
|
||||||
import Sidebar from 'src/components/layout/Sidebar'
|
import Sidebar from 'src/components/layout/Sidebar'
|
||||||
import TitleSection from 'src/components/layout/TitleSection'
|
import TitleSection from 'src/components/layout/TitleSection'
|
||||||
import ApolloProvider from 'src/utils/apollo'
|
import ApolloProvider from 'src/utils/apollo'
|
||||||
|
|
@ -69,8 +70,6 @@ const useStyles = makeStyles({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const AppContext = createContext()
|
|
||||||
|
|
||||||
const Main = () => {
|
const Main = () => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
|
|
@ -148,4 +147,3 @@ const App = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App
|
export default App
|
||||||
export { AppContext }
|
|
||||||
|
|
|
||||||
3
new-lamassu-admin/src/AppContext.js
Normal file
3
new-lamassu-admin/src/AppContext.js
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default React.createContext()
|
||||||
|
|
@ -1,10 +1,28 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
|
|
||||||
import App from './App'
|
|
||||||
import * as serviceWorker from './serviceWorker'
|
import * as serviceWorker from './serviceWorker'
|
||||||
|
|
||||||
ReactDOM.render(<App />, document.getElementById('root'))
|
function importBuildTarget() {
|
||||||
|
if (process.env.REACT_APP_BUILD_TARGET === 'LAMASSU') {
|
||||||
|
return import('./App')
|
||||||
|
} else if (process.env.REACT_APP_BUILD_TARGET === 'PAZUZ') {
|
||||||
|
return import('./pazuz/App')
|
||||||
|
} else {
|
||||||
|
return Promise.reject(
|
||||||
|
new Error('No such build target: ' + process.env.REACT_APP_BUILD_TARGET)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
importBuildTarget().then(({ default: Environment }) =>
|
||||||
|
ReactDOM.render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<Environment />
|
||||||
|
</React.StrictMode>,
|
||||||
|
document.getElementById('root')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
// If you want your app to work offline and load faster, you can change
|
// If you want your app to work offline and load faster, you can change
|
||||||
// unregister() to register() below. Note this comes with some pitfalls.
|
// unregister() to register() below. Note this comes with some pitfalls.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import gql from 'graphql-tag'
|
||||||
import React, { useState, useContext } from 'react'
|
import React, { useState, useContext } from 'react'
|
||||||
import { useHistory } from 'react-router-dom'
|
import { useHistory } from 'react-router-dom'
|
||||||
|
|
||||||
import { AppContext } from 'src/App'
|
import AppContext from 'src/AppContext'
|
||||||
import { getWizardStep, STEPS } from 'src/pages/Wizard/helper'
|
import { getWizardStep, STEPS } from 'src/pages/Wizard/helper'
|
||||||
import { backgroundColor } from 'src/styling/variables'
|
import { backgroundColor } from 'src/styling/variables'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
useLocation
|
useLocation
|
||||||
} from 'react-router-dom'
|
} from 'react-router-dom'
|
||||||
|
|
||||||
import { AppContext } from 'src/App'
|
import AppContext from 'src/AppContext'
|
||||||
import AuthRegister from 'src/pages/AuthRegister'
|
import AuthRegister from 'src/pages/AuthRegister'
|
||||||
import Blacklist from 'src/pages/Blacklist'
|
import Blacklist from 'src/pages/Blacklist'
|
||||||
import Cashout from 'src/pages/Cashout'
|
import Cashout from 'src/pages/Cashout'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue