1+ import { useState } from "react" ;
12import { useNavigate } from "react-router-dom" ;
23import trackClickEvent from "@/utils/trackClickEvent" ;
4+ import ActionConfirmModal from "@/components/modal/ActionConfirmModal" ;
5+ import useAuthStore from "@/store/useAuthStore" ;
36
47const SubTitle = ( { mode } : { mode : "빠른대화" | "친구목록" } ) => {
8+ const [ needLoginModalIsOpen , setNeedLoginModalIsOpen ] = useState ( false ) ;
9+ const { isLoggedIn } = useAuthStore ( ) ;
510 const navigate = useNavigate ( ) ;
611
712 const titleList = {
@@ -16,9 +21,11 @@ const SubTitle = ({ mode }: { mode: "빠른대화" | "친구목록" }) => {
1621 } ;
1722
1823 const handleNavigate = ( ) => {
19- const type = mode === "빠른대화" ? "fastFriend" : "virtualFriend" ;
2024 trackClickEvent ( "홈" , "친구 - 추가" ) ;
21- navigate ( "/select-info" , { state : { type : type } } ) ;
25+ if ( isLoggedIn ) {
26+ const type = mode === "빠른대화" ? "fastFriend" : "virtualFriend" ;
27+ navigate ( "/select-info" , { state : { type : type } } ) ;
28+ } else setNeedLoginModalIsOpen ( true ) ;
2229 } ;
2330
2431 return (
@@ -39,6 +46,16 @@ const SubTitle = ({ mode }: { mode: "빠른대화" | "친구목록" }) => {
3946 />
4047 </ button >
4148 ) }
49+ { needLoginModalIsOpen && (
50+ < ActionConfirmModal
51+ title = "로그인이 필요합니다."
52+ message = { [ `로그인 페이지로\n이동할까요?` ] }
53+ cancelText = "취소"
54+ confirmText = "확인"
55+ onCancel = { ( ) => setNeedLoginModalIsOpen ( false ) }
56+ onConfirm = { ( ) => navigate ( "/login" ) }
57+ />
58+ ) }
4259 </ div >
4360 ) ;
4461} ;
0 commit comments