import { Redirect } from 'react-router-dom';
import MainLayout from '../layouts/main';
import { useUser } from '../../hooks/react-query/use-user';
import { getNextRedirectURL } from '../utils/url';
import RegisterContent from './register-content';

function RegisterPage() {
  const { isAuthenticated } = useUser();
  if (isAuthenticated) return <Redirect to={getNextRedirectURL()} />;

  return (
    <MainLayout loginRequired={false} title={REGISTER_PAGE_TITLE}>
      <div data-testid='register' className='flex justify-center'>
        <div className='w-full w-full sm:w-3/4 lg:w-1/2'>
          <RegisterContent />
        </div>
      </div>
    </MainLayout>
  );
}

export const REGISTER_PAGE_TITLE = 'ثبت نام';

export default RegisterPage;
