import React from 'react';
import ReactDOM from 'react-dom';
import { history } from '@wisdom-utils/runtime';
import { Provider } from 'react-redux';
import { ConfigProvider, message, Modal, notification } from 'antd';
import { ConnectedRouter } from 'connected-react-router/immutable';
import { ErrorBoundary, LocaleContainer } from '@wisdom-utils/components';
import store from './stores';
import Container from './components/Container';
import App from './containers/App';
const MOUNT_NODE = document.getElementById('root');
const customPrefixCls = 'panda-console-base';
Modal.config({
  rootPrefixCls: customPrefixCls
});
message.config({
  rootPrefixCls: customPrefixCls
});
notification.config({
  rootPrefixCls: customPrefixCls
});
ConfigProvider.config({
  prefixCls: customPrefixCls,
});

export const render = () => {
  // eslint-disable-next-line react-hooks/rules-of-hooks
  ReactDOM.render(
    <Provider store={store}>
      <ConnectedRouter history={history}>
        <LocaleContainer>
          <ConfigProvider prefixCls={customPrefixCls}>
            <ErrorBoundary>
              <Container>
                <App />
              </Container>
            </ErrorBoundary>
          </ConfigProvider>
        </LocaleContainer>
      </ConnectedRouter>
    </Provider>,
    MOUNT_NODE,
  );
};
// updateTheme('#ff9600');
const loader = (appContent, loading) => render({ appContent, loading });

export default loader;
