251201_01_ENH : datatable, autocomplete, user관리 완성
This commit is contained in:
@@ -12,6 +12,8 @@ import { useAuth } from "@/hooks/useAuth";
|
||||
import { useLoading } from "@/hooks/useLoading";
|
||||
import { useStorage } from "@/hooks/useStorage"
|
||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||
import {apiError} from "@/lib/http-util";
|
||||
import commonConst from "@/config/commonConst";
|
||||
|
||||
const LoginPage = () => {
|
||||
const router = useRouter();
|
||||
@@ -49,7 +51,7 @@ const LoginPage = () => {
|
||||
// withLoading 래퍼로 API 호출 전/후 로딩 표시를 자동으로 처리
|
||||
return withLoadingAsync(() =>
|
||||
nextApi.post<LoginUser>(
|
||||
"/api/login", loginRequestBody, loginRequestOptions
|
||||
"/login", loginRequestBody, loginRequestOptions
|
||||
).then(async (data) => { // Jotai 기반 전역 인증 상태 갱신
|
||||
setFromLoginResponse(data, seatNum);
|
||||
// 요구사항: 페이지 이동 전에 SeatNumber를 secure-local-storage에 저장
|
||||
@@ -62,17 +64,19 @@ const LoginPage = () => {
|
||||
}
|
||||
// 메인 페이지로 이동 (보호 라우트 진입)
|
||||
router.replace("/");
|
||||
}).catch((err) => {
|
||||
if (err instanceof HttpError) {
|
||||
if (err.status === 401 || err.status === 403) {
|
||||
setError("아이디 또는 비밀번호를 다시 확인해주세요.");
|
||||
} else {
|
||||
setError(`로그인에 실패했습니다. (status: ${err.status})`);
|
||||
}
|
||||
} else {
|
||||
console.error(err);
|
||||
setError("알 수 없는 오류가 발생했습니다. 잠시 후 다시 시도해주세요.");
|
||||
}
|
||||
}).catch((e) => {
|
||||
const err = apiError(e);
|
||||
console.error(err.status, err.code, err.message);
|
||||
|
||||
if (err.status === 401 || err.status === 403) {
|
||||
setError("아이디 또는 비밀번호를 다시 확인해주세요.");
|
||||
}
|
||||
else if(err.code === commonConst.noneHttpError) {
|
||||
setError("알 수 없는 오류가 발생했습니다. 잠시 후 다시 시도해주세요.");
|
||||
}
|
||||
else {
|
||||
setError(`로그인에 실패했습니다. (status: ${err.status})`);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user