import Loader from '@/components/ui/Loader';
import AnimateFade from '@/components/wrap/AnimateFade';
import ExpectedAnonymous from '@/components/wrap/ExpectedAnonymous';
import { useAuth } from '@/context/AuthContext';

import FormSignup from './FormSignup';

function RegisterPage() {
  const { user, loading } = useAuth();

  if (loading) {
    return <Loader />;
  }
  if (user) {
    return (
      <AnimateFade>
        <ExpectedAnonymous />
      </AnimateFade>
    );
  }
  return (
    <AnimateFade key='signup-no-user'>
      <FormSignup />
    </AnimateFade>
  );
}

export default RegisterPage;
