import React from 'react';
import { useNavigate } from 'react-router-dom';
import { RegistrationContainer, PrelaunchEmailForm } from '../../components/domain/auth';
import { PublicLayout } from '../../components/layout';
import { PRELAUNCH_CONFIG } from '../../config/prelaunch';

const RegisterPage: React.FC = () => {
  const navigate = useNavigate();

  const handleRegistrationSuccess = () => {
    navigate('/app/onboarding');
  };

  const handleLoginClick = () => {
    navigate('/login');
  };

  // Show prelaunch email form or full registration based on build-time config
  if (PRELAUNCH_CONFIG.enabled) {
    return (
      <PublicLayout
        variant="centered"
        maxWidth="lg"
        headerProps={{
          showThemeToggle: true,
          showAuthButtons: false,
          showLanguageSelector: true,
          variant: "minimal"
        }}
      >
        <PrelaunchEmailForm
          onLoginClick={handleLoginClick}
          className="mx-auto"
        />
      </PublicLayout>
    );
  }

  return (
    <PublicLayout
      variant="centered"
      maxWidth="7xl"
      headerProps={{
        showThemeToggle: true,
        showAuthButtons: false,
        showLanguageSelector: true,
        variant: "minimal"
      }}
    >
      <RegistrationContainer
        onSuccess={handleRegistrationSuccess}
        onLoginClick={handleLoginClick}
        className="mx-auto"
      />
    </PublicLayout>
  );
};

export default RegisterPage;