import React from 'react';
import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';

import './setup';
import './versionInfo';
import { initServices } from './initServices';

import Routing from './Routing';
import { store } from './Store';
import { Services } from './ServiceLocator';

import { initLanguage } from './Translations';

export const App = () => (
    <Provider store={store}>
        <Routing />
    </Provider>
);

export const languageInitPromise = initLanguage({ store });

export const render = async () => {
    await languageInitPromise;
    createRoot(document.getElementById('root')).render(<App />);
};

export const main = async () => {
    await languageInitPromise;
    const services = initServices();
    Services.store.setStore(store);
    services.configurator.initialize();
};

export default App;
