diff --git a/public/error-puang.png b/public/error-puang.png
new file mode 100644
index 0000000..6450ae1
Binary files /dev/null and b/public/error-puang.png differ
diff --git a/src/app/constants/errorMessages.ts b/src/app/constants/errorMessages.ts
new file mode 100644
index 0000000..68a82fe
--- /dev/null
+++ b/src/app/constants/errorMessages.ts
@@ -0,0 +1,5 @@
+export const LOGIN_ERROR_MSG: string = '로그인에 실패했습니다.';
+export const LOGIN_ERROR_CHECK_MSG: string =
+ '아이디와 비밀번호를 다시 확인해주세요';
+export const GENERATION_ERROR_MSG: string = '프로필을 생성하는 실패했습니다.';
+export const GENERATION_ERROR_CHECK_MSG: string = '이미지를 다시 확인해주세요';
diff --git a/src/app/error/page.tsx b/src/app/error/page.tsx
new file mode 100644
index 0000000..0d08828
--- /dev/null
+++ b/src/app/error/page.tsx
@@ -0,0 +1,49 @@
+'use client';
+
+import { useAtom } from 'jotai';
+import Image from 'next/image';
+import { useEffect } from 'react';
+import { GENERATION_ERROR_MSG } from '@/app/constants/errorMessages';
+import PreviousPage from '@/components/PreviousPage';
+import {
+ errorCheckMessageAtom,
+ errorMessageAtom,
+} from '@/store/atoms/errorMessageAtom';
+
+export default function ErrorPage() {
+ const [errorMessage, setErrorMessage] = useAtom(errorMessageAtom);
+ const [errorCheckMessage, setErrorCheckMessage] = useAtom(
+ errorCheckMessageAtom,
+ );
+
+ useEffect(() => {
+ return () => {
+ setErrorMessage('');
+ setErrorCheckMessage('');
+ };
+ }, [setErrorMessage, setErrorCheckMessage]);
+
+ return (
+
+
+
+ Error
+ {errorMessage}
+
+ {errorCheckMessage}
+
+
+
+
+ );
+}
diff --git a/src/app/login/code/page.tsx b/src/app/login/code/page.tsx
index 57c9d15..5c77454 100644
--- a/src/app/login/code/page.tsx
+++ b/src/app/login/code/page.tsx
@@ -3,11 +3,21 @@
import { useSetAtom } from 'jotai';
import { useRouter, useSearchParams } from 'next/navigation';
import { useEffect } from 'react';
+import {
+ LOGIN_ERROR_CHECK_MSG,
+ LOGIN_ERROR_MSG,
+} from '@/app/constants/errorMessages';
+import {
+ errorCheckMessageAtom,
+ errorMessageAtom,
+} from '@/store/atoms/errorMessageAtom';
import { actionInsertToken } from '@/store/atoms/tokenActions';
export default function LoginCodePage() {
const router = useRouter();
const searchParams = useSearchParams();
+ const setErrorMessage = useSetAtom(errorMessageAtom);
+ const setErrorCheckMessage = useSetAtom(errorCheckMessageAtom);
const setInsertToken = useSetAtom(actionInsertToken);
useEffect(() => {
@@ -22,11 +32,18 @@ export default function LoginCodePage() {
router.push('/concept');
})
.catch(() => {
- // TODO - fail page로 이동
- router.push('/login');
+ setErrorMessage(LOGIN_ERROR_MSG);
+ setErrorCheckMessage(LOGIN_ERROR_CHECK_MSG);
+ router.push('/error');
});
}
- }, [setInsertToken, searchParams, router]);
+ }, [
+ setInsertToken,
+ searchParams,
+ router,
+ setErrorCheckMessage,
+ setErrorMessage,
+ ]);
return 로그인 처리중..
;
}
diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx
index 32c563e..1cf21ae 100644
--- a/src/app/login/page.tsx
+++ b/src/app/login/page.tsx
@@ -3,21 +3,29 @@
import { useSetAtom } from 'jotai';
import dynamic from 'next/dynamic';
import Image from 'next/image';
+import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
+import {
+ LOGIN_ERROR_CHECK_MSG,
+ LOGIN_ERROR_MSG,
+} from '@/app/constants/errorMessages';
import LoginButton from '@/app/login/_components/LoginButton';
import MyButton from '@/components/MyButton';
+import {
+ errorCheckMessageAtom,
+ errorMessageAtom,
+} from '@/store/atoms/errorMessageAtom';
import { actionInsertToken } from '@/store/atoms/tokenActions';
import login_character from '../../../public/login_page_img.png';
-/* 기본 글꼴은 cafe24 this is test */
-/* 이 글꼴은 sfpro
*/
-/* sfpro 글꼴 weight
*/
-/* 글꼴 색
*/
-/* This is Login Page
*/
-
function LoginView() {
+ const setErrorMessage = useSetAtom(errorMessageAtom);
+ const setErrorCheckMessage = useSetAtom(errorCheckMessageAtom);
const setInsertToken = useSetAtom(actionInsertToken);
+
+ const router = useRouter();
const storedToken = window.sessionStorage.getItem('accessToken') || '';
+
useEffect(() => {
if (storedToken !== '') {
fetch(
@@ -29,22 +37,33 @@ function LoginView() {
const reissueResponse = await fetch(
`${process.env.NEXT_PUBLIC_CLIENT_ADDRESS}:${process.env.NEXT_PUBLIC_CLIENT_PORT}/api/reissue?code=${storedToken}`,
);
- // TODO- ok가 아닌경우, ok이지만 accessToken이 없는 경우 fail page로 이동 필요
if (reissueResponse.ok) {
const reissueData = await reissueResponse.json();
setInsertToken(reissueData.accessToken);
} else {
setInsertToken('');
+ setErrorMessage(LOGIN_ERROR_MSG);
+ setErrorCheckMessage(LOGIN_ERROR_CHECK_MSG);
+ router.push('/error');
}
}
})
.catch(() => {
setInsertToken('');
+ setErrorMessage(LOGIN_ERROR_MSG);
+ setErrorCheckMessage(LOGIN_ERROR_CHECK_MSG);
+ router.push('/error');
});
} else {
setInsertToken(storedToken);
}
- }, [storedToken, setInsertToken]);
+ }, [
+ router,
+ storedToken,
+ setInsertToken,
+ setErrorMessage,
+ setErrorCheckMessage,
+ ]);
return (
diff --git a/src/store/atoms/errorMessageAtom.ts b/src/store/atoms/errorMessageAtom.ts
new file mode 100644
index 0000000..865fdd4
--- /dev/null
+++ b/src/store/atoms/errorMessageAtom.ts
@@ -0,0 +1,4 @@
+import { atom } from 'jotai';
+
+export const errorMessageAtom = atom('');
+export const errorCheckMessageAtom = atom('');