import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import Modal from '~/common/components/elements/Modal';
import { getAuth } from '~/common/libs/auth';
import PageContent from '../page-content';
import Link from 'next/link';

const PagePopupInformation = () => {
  const router = useRouter();
  const isHomePage = router.pathname === '/';
  const auth = getAuth();
  const [active, setActive] = useState<boolean>(false);

  useEffect(() => {
    if (isHomePage && !auth) {
      setActive(true);
    }
  }, [isHomePage, auth]);
  return (
    <div className='group'>
      <Modal
        active={active}
        className='!w-fit !bg-transparent !border-none overflow-hidden'
        close={() => setActive(false)}
        mode='desktop'
      >
        <div className='w-[350px] md:w-[530px] '>
          <Link href={'/register'}>
            <PageContent path='/onbording-popup' />
          </Link>
          {/* <Link href={'/register'} className='btn-yellow w-full mt-2'>
            Daftar Sekarang
          </Link> */}
        </div>
      </Modal>
    </div>
  );
};

export default PagePopupInformation;
