diff --git a/packages/client/src/page/loginPage.tsx b/packages/client/src/page/loginPage.tsx index 882f16b..125978f 100644 --- a/packages/client/src/page/loginPage.tsx +++ b/packages/client/src/page/loginPage.tsx @@ -5,54 +5,124 @@ import { Label } from "@/components/ui/label.tsx"; import { doLogin } from "@/state/user.ts"; import { useState } from "react"; import { useLocation } from "wouter"; +import { Eye, EyeOff } from "lucide-react"; +import { LogInIcon, User, Loader2 } from "lucide-react"; export function LoginForm() { - const [username, setUsername] = useState(""); - const [password, setPassword] = useState(""); - const [, setLocation] = useLocation(); + const [username, setUsername] = useState(""); + const [password, setPassword] = useState(""); + const [isLoading, setIsLoading] = useState(false); + const [showPassword, setShowPassword] = useState(false); + const [, setLocation] = useLocation(); - return ( - - - Login - - Enter your email below to login to your account. - - - -
- - setUsername(e.target.value)}/> + const handleLogin = async () => { + if (!username || !password) { + alert("사용자 이름과 비밀번호를 입력해주세요."); + return; + } + + setIsLoading(true); + try { + const result = await doLogin({ + username, + password, + }); + + if (typeof result === "string") { + alert(result); + } else { + setLocation("/"); + } + } catch (error) { + alert("로그인 중 오류가 발생했습니다."); + console.error(error); + } finally { + setIsLoading(false); + } + }; + + return ( + + + + + + + Login + + + Enter your email below to login to your account. + + + +
+ + setUsername(e.target.value)} + /> +
+
+ +
+ setPassword(e.target.value)} + /> +
-
- - setPassword(e.target.value)}/> -
- - - - - - ) +
+
+ + + +
+ ) } export function LoginPage() { - return ( -
+ return ( +
+
- ) +
+ ) } export default LoginPage; \ No newline at end of file diff --git a/packages/client/src/state/user.ts b/packages/client/src/state/user.ts index ce8dd54..02e71ae 100644 --- a/packages/client/src/state/user.ts +++ b/packages/client/src/state/user.ts @@ -97,6 +97,12 @@ export const doLogin = async (userLoginInfo: LoginRequest): Promise { const u = makeApiUrl("/api/user/reset"); const res = await fetch(u, {