"use client"; import React from "react"; import { Button } from "@/app/components/ui/Button"; import { useToast } from "@/app/components/ui/ToastProvider"; export default function LoginPage() { const { show } = useToast(); const [nickname, setNickname] = React.useState(""); const [password, setPassword] = React.useState(""); const [loading, setLoading] = React.useState(false); const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); try { const res = await fetch("/api/auth/session", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ nickname, password }), }); const data = await res.json(); if (!res.ok) throw new Error(data?.error || "로그인 실패"); show("로그인되었습니다"); location.href = "/"; } catch (err: any) { show(err.message || "로그인 실패"); } finally { setLoading(false); } }; return (

로그인

setNickname(e.target.value)} style={{ padding: 8, border: "1px solid #ddd", borderRadius: 6 }} /> setPassword(e.target.value)} style={{ padding: 8, border: "1px solid #ddd", borderRadius: 6 }} />
회원가입
); }