import { createFileRoute, redirect } from "@tanstack/react-router";
import SignUpForm from "@/components/sign-up-form";
import { isOnboardingNeeded } from "@/utils/functions";

export const Route = createFileRoute("/signup")({
	component: RouteComponent,
	beforeLoad: async () => {
		const needsOnboarding = await isOnboardingNeeded();
		if (needsOnboarding.needsOnboarding) {
			throw redirect({
				to: "/welcome",
			});
		}
	},
	head: () => ({
		meta: [
			{
				title: "Sign Up - Nontara",
			},
		],
	}),
});

function RouteComponent() {
	return (
		<div className="flex min-h-screen items-center justify-center p-4">
			<SignUpForm />
		</div>
	);
}
