From 968e7b72020a0fe0f26c3c6f0830519ad768afa5 Mon Sep 17 00:00:00 2001 From: liupei8979 Date: Sat, 28 Sep 2024 12:35:21 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20-=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/login.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 6c1ec8f3..16c63aef 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -1,9 +1,27 @@ +import { API } from '../lib/api'; import cn from '../lib/cn.ts'; import { useNavigate } from 'react-router-dom'; +import { useState } from 'react'; export default function Login() { const navigate = useNavigate(); + // 입력 필드 상태 관리 + const [username, setUsername] = useState(''); + const [password, setPassword] = useState(''); + + const handleLogin = async () => { + try { + // 로그인 요청 + await API.User.login(username, password); + alert('로그인 성공!'); + navigate('/'); // 로그인 성공 시 메인 페이지로 이동 + } catch (error) { + console.error('로그인 실패:', error); + alert('로그인에 실패했습니다.'); + } + }; + return (
setUsername(e.target.value)} /> setPassword(e.target.value)} />
@@ -47,6 +69,7 @@ export default function Login() { 'w-[500px] h-[70px] bg-[#5A82F1] text-white font-bold rounded', 'hover:bg-[#4A72D1] focus:outline-none focus:ring-2 focus:ring-[#5A82F1]' )} + onClick={handleLogin} // 로그인 버튼 클릭 시 실행 > 로그인