import React from 'react';
import { IntlProvider } from "react-intl"
import { AuthenticationProvider, AuthenticationRequired } from "lib/Authentication"
import ApolloClientProvider from "lib/ApolloClient";
import ErrorBoundary from "boundaries/ErrorBoundary";
import PageNotFoundBoundary from "boundaries/PageNotFoundBoundary";
import { Router, Routes } from "./Routes";
import PageLayout from "components/PageLayout";

const App: React.FC = () => {
  return (
    <IntlProvider locale={navigator.language}>
      <ErrorBoundary>
        <AuthenticationProvider>
          <ApolloClientProvider>
            <Router>
              <PageLayout>
                <PageNotFoundBoundary>
                  <AuthenticationRequired>
                    <Routes />
                  </AuthenticationRequired>
                </PageNotFoundBoundary>
              </PageLayout>
            </Router>
          </ApolloClientProvider>
        </AuthenticationProvider>
      </ErrorBoundary>
    </IntlProvider>
  );
};

export default App;