import { BrowserRouter } from 'react-router-dom'

import { getLanguageUrlParam } from 'helpers/languageUrlParam'
import {
  setClientTitleAndDescription,
  setClientIcons,
} from 'helpers/setClientHeads'

import { GlobalStyles } from 'features/GlobalStyles'
import { LexicsStore } from 'features/LexicsStore'
import { Theme } from 'features/Theme'

import { App } from './components/App'
import { client } from './config/clients'

setClientTitleAndDescription(client.title, client.description)
setClientIcons(client.name)

const Background = client.background
const initialLanguage = getLanguageUrlParam()

const AuthServiceApp = () => (
  <BrowserRouter>
    <Theme>
      <GlobalStyles />
      <LexicsStore initialLanguage={initialLanguage}>
        <Background>
          <App />
        </Background>
      </LexicsStore>
    </Theme>
  </BrowserRouter>
)

export default AuthServiceApp
