2018-05-21 20:03:46 +00:00
|
|
|
// License: LGPL-3.0-or-later
|
|
|
|
import * as React from 'react';
|
2018-06-29 18:13:31 +00:00
|
|
|
import {observer, Provider} from 'mobx-react';
|
2020-06-30 21:41:47 +00:00
|
|
|
import {IntlProvider} from 'react-intl';
|
2018-05-21 20:03:46 +00:00
|
|
|
import {convert} from 'dotize'
|
|
|
|
import {ApiManager} from "../../lib/api_manager";
|
|
|
|
import {APIS} from "../../../api";
|
|
|
|
import {CSRFInterceptor} from "../../lib/csrf_interceptor";
|
|
|
|
|
|
|
|
import * as CustomAPIS from "../../lib/apis"
|
|
|
|
|
2020-11-24 22:20:51 +00:00
|
|
|
const I18n = require('../../../../i18n').default
|
2018-05-21 20:03:46 +00:00
|
|
|
|
|
|
|
interface RootProps
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@observer
|
|
|
|
export default class Root extends React.Component<RootProps, {}> {
|
|
|
|
|
|
|
|
apiManager: ApiManager
|
|
|
|
|
2018-05-24 15:06:44 +00:00
|
|
|
componentDidMount(){
|
|
|
|
let pageProgress = (window as any).pageProgress
|
|
|
|
if (pageProgress && pageProgress.finishPageLoad){
|
|
|
|
pageProgress.finishPageLoad()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-05-21 20:03:46 +00:00
|
|
|
render() {
|
|
|
|
if (!this.apiManager){
|
|
|
|
this.apiManager = new ApiManager(APIS.concat(CustomAPIS.APIS as Array<any>), CSRFInterceptor)
|
|
|
|
}
|
|
|
|
|
2020-07-31 02:03:07 +00:00
|
|
|
return <IntlProvider locale={I18n.locale} defaultLocale={I18n.defaultLocale} messages={convert(I18n.translations[I18n.locale]) as any}>
|
2018-05-21 20:03:46 +00:00
|
|
|
<Provider ApiManager={this.apiManager}>
|
|
|
|
{this.props.children}
|
|
|
|
</Provider>
|
|
|
|
</IntlProvider>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|