import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';

import { Modal } from "~/components/ui/modal";
import { getAuth } from '~/libs/auth';
import PageContent from '../page-content';

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]' onClick={() => setActive(false)}>
          <PageContent path='/onbording-popup' />
        </div>
      </Modal>
    </div>
  );
};

export default PagePopupInformation;
