diff --git a/src/App.tsx b/src/App.tsx
index a7bd089..f9bbcaf 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -118,7 +118,7 @@ const App = () => {
} />
} />
} />
- } />
+ } />
} />
diff --git a/src/pages/MbtiTestResult.tsx b/src/pages/MbtiTestResult.tsx
index f8a00e1..2572145 100644
--- a/src/pages/MbtiTestResult.tsx
+++ b/src/pages/MbtiTestResult.tsx
@@ -4,9 +4,10 @@ import RestartButton from "@/components/button/RestartButton";
import ChatStartButton from "@/components/button/ChatStartButton";
import useLayoutSize from "@/hooks/useLayoutSize";
import Header from "@/components/header/Header";
+import { useParams } from "react-router-dom";
const MbtiTestResult = () => {
- const mbti = localStorage.getItem("mbti-test-mbti") ?? "";
+ const { mbti } = useParams();
const result = MBTI_RESULT_INFO[mbti as keyof typeof MBTI_RESULT_INFO];
const size = useLayoutSize();
const imageURL =
diff --git a/src/store/useMbtiTestState.ts b/src/store/useMbtiTestState.ts
index cc614fc..04ef13b 100644
--- a/src/store/useMbtiTestState.ts
+++ b/src/store/useMbtiTestState.ts
@@ -5,6 +5,7 @@ type PageNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
interface MbtiTestState {
currentPage: PageNumber;
currentMbti: string;
+ pageIsCompleted: Record;
mbtiLog: Record;
setNextStep: () => void;
setPreviousStep: () => void;
@@ -18,6 +19,20 @@ interface MbtiTestState {
const useMbtiTestState = create((set, get) => ({
currentPage: 1,
currentMbti: "",
+ pageIsCompleted: {
+ 1: false,
+ 2: false,
+ 3: false,
+ 4: false,
+ 5: false,
+ 6: false,
+ 7: false,
+ 8: false,
+ 9: false,
+ 10: false,
+ 11: false,
+ 12: false
+ },
mbtiLog: {
E: 0,
I: 0,
@@ -30,6 +45,7 @@ const useMbtiTestState = create((set, get) => ({
},
setNextStep: () => {
const currentPage = get().currentPage;
+ const currentMbti = get().currentMbti;
const setPageComplete = get().setPageComplete;
setPageComplete(currentPage); // 현재 페이지를 완료로 설정
@@ -37,7 +53,8 @@ const useMbtiTestState = create((set, get) => ({
// 마지막 페이지라면 결과 페이지로 이동
if (currentPage === 12) {
get().getMbtiByLog();
- if (get().currentMbti !== "") window.location.href = "/mbti-test-result";
+ if (currentMbti !== "")
+ window.location.href = `/mbti-test-result/${currentMbti}`;
else console.error("mbti가 비어있습니다.");
} else {
// 그렇지 않다면 페이지를 증가시킴