내부 api 삭제
This commit is contained in:
@@ -20,13 +20,57 @@ export default function LoginPage() {
|
||||
const [idError, setIdError] = useState("");
|
||||
const [passwordError, setPasswordError] = useState("");
|
||||
|
||||
function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
||||
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
||||
e.preventDefault();
|
||||
// 실제 로그인 API 연동 전까지는 실패 모달을 노출합니다.
|
||||
// API 연동 시 결과에 따라 성공/실패 분기에서 setIsLoginErrorOpen(true) 호출로 교체하세요.
|
||||
// if (userId.trim().length > 0 && password.trim().length > 0) {
|
||||
// setIsLoginErrorOpen(true);
|
||||
// }
|
||||
if (userId.trim().length === 0 || password.trim().length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch("https://hrdi.coconutmeet.net/auth/login", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json",},
|
||||
body: JSON.stringify({
|
||||
email: userId,
|
||||
password: password
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
let errorMessage = `로그인 실패 (${response.status})`;
|
||||
try {
|
||||
const errorData = await response.json();
|
||||
if (errorData.error) {
|
||||
errorMessage = errorData.error;
|
||||
} else if (errorData.message) {
|
||||
errorMessage = errorData.message;
|
||||
} else if (response.statusText) {
|
||||
errorMessage = `${response.statusText} (${response.status})`;
|
||||
}
|
||||
} catch (parseError) {
|
||||
if (response.statusText) {
|
||||
errorMessage = `${response.statusText} (${response.status})`;
|
||||
}
|
||||
}
|
||||
console.error("로그인 실패:", errorMessage);
|
||||
setIsLoginErrorOpen(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log("로그인 성공:", data);
|
||||
|
||||
// 로그인 성공 시 처리 (예: 토큰 저장, 리다이렉트 등)
|
||||
// TODO: 성공 시 처리 로직 추가 (예: localStorage에 토큰 저장, 메인 페이지로 이동 등)
|
||||
// if (data.token) {
|
||||
// localStorage.setItem('token', data.token);
|
||||
// window.location.href = '/menu';
|
||||
// }
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : "네트워크 오류가 발생했습니다.";
|
||||
console.error("로그인 오류:", errorMessage);
|
||||
setIsLoginErrorOpen(true);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -106,12 +150,12 @@ export default function LoginPage() {
|
||||
onBlur={() => setIsPasswordFocused(false)}
|
||||
placeholder="비밀번호"
|
||||
className="
|
||||
h-[40px] px-[12px] py-[7px] rounded-[8px] w-full border border-neutral-40
|
||||
focus:outline-none focus:ring-0 focus:ring-offset-0 focus:shadow-none
|
||||
focus:appearance-none focus:border-neutral-700
|
||||
text-[18px] text-neutral-700 font-normal leading-[150%] placeholder:text-input-placeholder-text
|
||||
pr-[40px]
|
||||
"
|
||||
h-[40px] px-[12px] py-[7px] rounded-[8px] w-full border border-neutral-40
|
||||
focus:outline-none focus:ring-0 focus:ring-offset-0 focus:shadow-none
|
||||
focus:appearance-none focus:border-neutral-700
|
||||
text-[18px] text-neutral-700 font-normal leading-[150%] placeholder:text-input-placeholder-text
|
||||
pr-[40px]
|
||||
"
|
||||
/>
|
||||
{password.trim().length > 0 && isPasswordFocused && (
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user