2020-12-05 02:47:02 -05:00
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import { IntlProvider } from 'react-intl'
|
|
|
|
|
2020-12-11 20:06:42 -08:00
|
|
|
import { GlobalStyle } from './theme/global-style';
|
|
|
|
import RegistrationSuccessPage from './components/registration-success-page';
|
|
|
|
import ForgotPasswordSuccessPage from './components/forgot-password-success-page';
|
|
|
|
import RegistationPage from './components/registration-page';
|
2020-12-07 23:34:01 -08:00
|
|
|
import LoginPage from './components/login-page';
|
2020-12-24 17:39:06 -08:00
|
|
|
import MapsPage from './components/maps-page';
|
|
|
|
import store from "./store"
|
2020-12-07 23:14:08 -08:00
|
|
|
|
2020-12-05 02:47:02 -05:00
|
|
|
import {
|
|
|
|
Route,
|
|
|
|
Switch,
|
2020-12-05 22:35:21 -08:00
|
|
|
Redirect,
|
2020-12-06 08:24:53 -08:00
|
|
|
BrowserRouter as Router,
|
2020-12-05 02:47:02 -05:00
|
|
|
} from 'react-router-dom';
|
2020-12-09 22:29:28 -08:00
|
|
|
|
2020-12-07 23:34:01 -08:00
|
|
|
import { ForgotPasswordPage } from './components/forgot-password-page';
|
2020-12-24 17:39:06 -08:00
|
|
|
import { Provider } from 'react-redux';
|
2020-12-05 02:47:02 -05:00
|
|
|
|
2020-12-05 21:28:00 -08:00
|
|
|
function loadLocaleData(language: string) {
|
2020-12-05 02:47:02 -05:00
|
|
|
switch (language) {
|
|
|
|
case 'es':
|
2020-12-05 21:28:00 -08:00
|
|
|
return require('./compiled-lang/es.json')
|
2020-12-05 02:47:02 -05:00
|
|
|
default:
|
2020-12-05 21:28:00 -08:00
|
|
|
return require('./compiled-lang/en.json')
|
2020-12-05 02:47:02 -05:00
|
|
|
}
|
2020-12-24 17:39:06 -08:00
|
|
|
}
|
2020-12-05 02:47:02 -05:00
|
|
|
|
2020-12-12 12:23:38 -08:00
|
|
|
type AppProps = {
|
|
|
|
baseRestUrl: string;
|
|
|
|
}
|
|
|
|
|
2020-12-24 17:39:06 -08:00
|
|
|
const App = () => {
|
2020-12-05 02:47:02 -05:00
|
|
|
const [messages, setMessages] = useState(undefined);
|
|
|
|
|
|
|
|
// Boostrap i18n ...
|
|
|
|
const locale = (navigator.languages && navigator.languages[0])
|
|
|
|
|| navigator.language
|
|
|
|
|| 'en-US';
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const language = locale.split('-')[0];
|
|
|
|
const fetchData = async () => {
|
|
|
|
const messages = await loadLocaleData(language);
|
|
|
|
setMessages(messages);
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchData();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return messages ? (
|
2020-12-24 17:39:06 -08:00
|
|
|
<Provider store={store}>
|
|
|
|
<IntlProvider locale={locale} defaultLocale='en' messages={messages}>
|
|
|
|
<GlobalStyle />
|
|
|
|
<Router>
|
|
|
|
<Switch>
|
|
|
|
<Route exact path="/">
|
|
|
|
<Redirect to="/c/login" />
|
|
|
|
</Route>
|
|
|
|
<Route path="/c/login" component={LoginPage} />
|
|
|
|
<Route path="/c/registration">
|
|
|
|
<RegistationPage />
|
|
|
|
</Route>
|
|
|
|
<Route path="/c/registration-success" component={RegistrationSuccessPage} />
|
|
|
|
<Route path="/c/forgot-password">
|
|
|
|
<ForgotPasswordPage />
|
|
|
|
</Route>
|
|
|
|
<Route path="/c/forgot-password-success" component={ForgotPasswordSuccessPage} />
|
|
|
|
<Route path="/c/maps/">
|
|
|
|
<MapsPage />
|
|
|
|
</Route>
|
|
|
|
</Switch>
|
|
|
|
</Router>
|
|
|
|
</IntlProvider>
|
|
|
|
</Provider>
|
|
|
|
|
2020-12-09 19:33:30 -08:00
|
|
|
) : <div>Loading ... </div>
|
2020-12-05 02:47:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|