"use client"; import { useState } from "react"; import { Button } from "./ui/button"; import { Input } from "./ui/input"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./ui/card"; import { useAuth } from "./AuthProvider"; export function LoginForm() { const { login, register } = useAuth(); const [nickname, setNickname] = useState(""); const [password, setPassword] = useState(""); const [isRegister, setIsRegister] = useState(false); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setLoading(true); const fn = isRegister ? register : login; const err = await fn(nickname, password); if (err) setError(err); setLoading(false); }; return (
🤡💥
BaraBingo {isRegister ? "SUB CREW REGISTRATION" : "SUB NETWORK LOGIN"}
setNickname(e.target.value)} required minLength={2} maxLength={20} className="font-mono" />
setPassword(e.target.value)} required minLength={4} className="font-mono" />
{error && (
âš  {error}
)}
); }