import { BrowserRouter, Link } from 'react-router-dom';
import styled from 'styled-components';

import GlobalStyles from './styles/GlobalStyles';
import RouteInfo from './RouteInfo';

import './i18n';
import { AlertProvider } from './context/AlertProvider';
import { LoadingProvider } from './context/LoadingProvider';

function App() {
	const isToken = sessionStorage.getItem('token') ? true : false;

	return (
		<AlertProvider>
			<LoadingProvider>
				<BrowserRouter>
					<GlobalStyles />
					<ControllLink>{isToken ? <Link to="/main" /> : <Link to="/fail" />}</ControllLink>
					<RouteInfo />
				</BrowserRouter>
			</LoadingProvider>
		</AlertProvider>
	);
}

export default App;

const ControllLink = styled.div`
	position: absolute;
`;
