import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { useState } from "react";

export const Route = createFileRoute("/auth/username")({
	component: RouteComponent,
});

function RouteComponent() {
	const [username, setUsername] = useState("");
	const navigate = useNavigate();

	const handleSubmit = () => {
		if (username.trim() === "") return;
		navigate({
			to: "/",
			viewTransition: { types: ["warp"] },
		});
	};

	return (
		<div className="flex items-center justify-center h-full gap-10 tracking-[-2%] flex-col">
			<div className="text-brand-gray text-center">
				<p className="font-medium text-[48px] leading-[120%] ">
					Welcome to Cytonic!
				</p>
				<p className="font-medium text-[32px] leading-[120%]">Sign in</p>
				<p className="text-text-light-200 whitespace-nowrap mt-4">
					Create a username
				</p>
			</div>

			<div className="space-y-6 w-[300px]">
				<Input
					label="Username"
					placeholder="Pink Axolotl"
					value={username}
					onChange={(e) => setUsername(e.target.value)}
					onKeyDown={(e) => {
						if (e.key === "Enter") {
							handleSubmit();
						}
					}}
				/>

				<div className="space-y-2">
					<Button
						className="text-[18px] w-full"
						disabled={username.trim() === ""}
						onClick={handleSubmit}
					>
						Confirm
					</Button>
					<Button
						variant={"secondary"}
						className="text-[18px] w-full"
						// onClick={handleSubmit}
					>
						Skip for now
					</Button>
				</div>
			</div>
		</div>
	);
}
