diff --git a/src/components/StrokeBanner.tsx b/src/components/StrokeBanner.tsx index dfd6983..87ea8a6 100644 --- a/src/components/StrokeBanner.tsx +++ b/src/components/StrokeBanner.tsx @@ -1,11 +1,20 @@ +import { useState } from "react"; import { useNavigate } from "react-router-dom"; +import ActionConfirmModal from "@/components/modal/ActionConfirmModal"; +import useAuthStore from "@/store/useAuthStore"; const StrokeBanner = () => { + const [needLoginModalIsOpen, setNeedLoginModalIsOpen] = useState(false); + const { isLoggedIn } = useAuthStore(); const navigate = useNavigate(); const handleNavigate = () => { - const mode = "virtualFriend"; - navigate("/select-info", { state: { type: mode } }); + if (isLoggedIn) { + const mode = "virtualFriend"; + navigate("/select-info", { state: { type: mode } }); + } else { + setNeedLoginModalIsOpen(true); + } }; return ( @@ -27,6 +36,16 @@ const StrokeBanner = () => {
입력해서 빠르게 대화할 수 있어요

+ {needLoginModalIsOpen && ( + setNeedLoginModalIsOpen(false)} + onConfirm={() => navigate("/login")} + /> + )} ); }; diff --git a/src/components/SubTitle.tsx b/src/components/SubTitle.tsx index bb165a4..f55ebc1 100644 --- a/src/components/SubTitle.tsx +++ b/src/components/SubTitle.tsx @@ -1,6 +1,11 @@ +import { useState } from "react"; import { useNavigate } from "react-router-dom"; +import ActionConfirmModal from "@/components/modal/ActionConfirmModal"; +import useAuthStore from "@/store/useAuthStore"; const SubTitle = ({ mode }: { mode: "빠른대화" | "친구목록" }) => { + const [needLoginModalIsOpen, setNeedLoginModalIsOpen] = useState(false); + const { isLoggedIn } = useAuthStore(); const navigate = useNavigate(); const titleList = { @@ -15,8 +20,10 @@ const SubTitle = ({ mode }: { mode: "빠른대화" | "친구목록" }) => { }; const handleNavigate = () => { - const type = mode === "빠른대화" ? "fastFriend" : "virtualFriend"; - navigate("/select-info", { state: { type: type } }); + if (isLoggedIn) { + const type = mode === "빠른대화" ? "fastFriend" : "virtualFriend"; + navigate("/select-info", { state: { type: type } }); + } else setNeedLoginModalIsOpen(true); }; return ( @@ -37,6 +44,16 @@ const SubTitle = ({ mode }: { mode: "빠른대화" | "친구목록" }) => { /> )} + {needLoginModalIsOpen && ( + setNeedLoginModalIsOpen(false)} + onConfirm={() => navigate("/login")} + /> + )} ); }; diff --git a/src/components/modal/ActionConfirmModal.tsx b/src/components/modal/ActionConfirmModal.tsx index cc2f447..6564d55 100644 --- a/src/components/modal/ActionConfirmModal.tsx +++ b/src/components/modal/ActionConfirmModal.tsx @@ -27,7 +27,7 @@ const ActionConfirmModal = ({ onClick={(e) => e.stopPropagation()} >

{title}

-

+

{message.map((line, index) => ( {line}