diff --git a/web/src/lib/cookie.ts b/web/src/lib/cookie.ts index 534efe4..015e7ed 100644 --- a/web/src/lib/cookie.ts +++ b/web/src/lib/cookie.ts @@ -1,5 +1,7 @@ import cookie from "js-cookie"; +export const nameKey = 'namekey'; + class Cookie { public getCookie(key: string): string | undefined { let item = undefined; diff --git a/web/src/page/play/PlayPage.tsx b/web/src/page/play/PlayPage.tsx index a2a61ca..60e581f 100644 --- a/web/src/page/play/PlayPage.tsx +++ b/web/src/page/play/PlayPage.tsx @@ -1,5 +1,4 @@ import React, {useEffect, useState} from "react"; -import {useLocation} from "react-router-dom"; import EndDialog from "@src/component/dialog/enddialog/EndDialog"; import Scene1Page from "@src/page/play/scene/scene1/Scene1Page"; import Scene2Page from "@src/page/play/scene/scene2/Scene2Page"; @@ -16,22 +15,21 @@ import Scene12Page from "@src/page/play/scene/scene12/Scene12Page"; import Scene13Page from "@src/page/play/scene/scene13/Scene13Page"; import FutureDialog from "@src/component/dialog/futuredialog/FutureDialog"; import useNav from "@hook/useNav"; +import cookie1, {nameKey} from "@lib/cookie"; export default function PlayPage() { const {toHome} = useNav(); const [scene, setScene] = useState(1); - const location = useLocation(); - const name = location.state.name; + let name = cookie1.getCookie(nameKey); if (!name) { toHome(); } + name = name ?? ''; const [isShowEndDialog, setIsShowEndDialog] = useState(false); const [isShowFutureDialog, setIsShowFutureDialog] = useState(false) - const [playData, setPlayData] = useState([]) - function nextScene() { setScene(scene + 1); } diff --git a/web/src/page/play/scene/ScenePage.tsx b/web/src/page/play/scene/ScenePage.tsx index 99849ba..0b52d2a 100644 --- a/web/src/page/play/scene/ScenePage.tsx +++ b/web/src/page/play/scene/ScenePage.tsx @@ -6,8 +6,8 @@ import TypingText from "@src/component/TypingText"; import PlaySong from "@src/designsystem/util/PlaySong"; import SelectText from "@src/component/SelectText"; import Loader from "@src/component/loader/Loader"; -import {useLocation} from "react-router-dom"; import useNav from "@hook/useNav"; +import cookie1, {nameKey} from "@lib/cookie"; interface ScenePageProps { backgroundUrl: string; @@ -17,8 +17,7 @@ interface ScenePageProps { function ScenePage(props: ScenePageProps) { const {toHome} = useNav(); - const location = useLocation(); - const name = location.state.name; + const name = cookie1.getCookie(nameKey); if (!name) { toHome(); } diff --git a/web/src/page/start/StartPage.tsx b/web/src/page/start/StartPage.tsx index bfa47c8..8be9ad4 100644 --- a/web/src/page/start/StartPage.tsx +++ b/web/src/page/start/StartPage.tsx @@ -4,6 +4,7 @@ import {Background} from "@src/component/Background.style"; import ExpandRight from "@designsystem/foundation/iconography/icons/ExpandRight"; import {useNavigate} from "react-router-dom"; import {StartButton} from "@src/component/StartButton.style"; +import cookie1, {nameKey} from "@lib/cookie"; export default function StartPage() { @@ -101,11 +102,8 @@ export default function StartPage() { { - navigate('play', { - state: { - name - } - }); + navigate('play'); + cookie1.setCookie(nameKey, name); }} > μ‹œμž‘ν•˜κΈ°