"use client";

import { useState } from "react";
import RegisterForm from "@/app/register/RegisterForm";
import RegisterOption from "@/app/register/RegisterOption";
import RegisterDone from "@/app/register/RegisterDone";
import RegisterCodeErrorModal from "@/app/register/RegisterCodeErrorModal";

export default function RegisterPage() {
	const [doneOpen, setDoneOpen] = useState(false);
	const [codeErrorOpen, setCodeErrorOpen] = useState(false);
	const [codeErrorMessage, setCodeErrorMessage] = useState<string | undefined>(undefined);

	return (
		<>
			<div className="min-h-screen w-full flex flex-col items-center justify-between">
				
				<RegisterForm
					onOpenDone={() => setDoneOpen(true)}
					onOpenCodeError={(msg) => {
						setCodeErrorMessage(msg);
						setCodeErrorOpen(true);
					}}
				/>

				<RegisterOption
					doneOpen={doneOpen}
					setDoneOpen={setDoneOpen}
					codeErrorModalEnabled={codeErrorOpen}
					setCodeErrorModalEnabled={setCodeErrorOpen}
				/>
				<p className="text-center py-[40px] text-[15px] text-basic-text">
					Copyright ⓒ 2025 XL LMS. All rights reserved
				</p>
			</div>

			<RegisterDone
				open={doneOpen}
				onClose={() => setDoneOpen(false)}
			/>
			<RegisterCodeErrorModal
				open={codeErrorOpen}
				onClose={() => setCodeErrorOpen(false)}
				message={codeErrorMessage}
			/>
		</>
	);
}


