import { useEffect } from 'react';
import { useRouter } from 'next/router';
import Seo from '@/core/components/Seo';
import SimpleFooter from '@/core/components/elements/Footer/SimpleFooter';
import BasicLayout from '@/core/components/layouts/BasicLayout';
import DesktopView from '@/core/components/views/DesktopView';
import MobileView from '@/core/components/views/MobileView';
import LoginComponent from '@/lib/auth/components/Login';
import AccountActivation from '~/modules/account-activation';
import useAuth from '@/core/hooks/useAuth';

export default function Login() {
  const router = useRouter();
  const auth = useAuth();

  useEffect(() => {
    if (auth) {
      router.push('/');
    }
  }, [auth, router]);

  return (
    <>
      <Seo title='Login - Indoteknik.com' />

      <DesktopView>
        <BasicLayout>
          <LoginComponent />
        </BasicLayout>
      </DesktopView>

      <MobileView>
        <LoginComponent />
        <SimpleFooter />
      </MobileView>

      <AccountActivation />
    </>
  );
}
