@@ -14,6 +14,8 @@ import useDevice from '../hooks/useDevice';
1414import { postThemeLikeAPI , deleteThemeLikeAPI } from '../../features/like/api/themeLikeAPI' ;
1515import PopUpModal from './PopUpModal' ;
1616import useAuthSession from '../hooks/useAuthSession' ;
17+ import { scheduleModalState } from '../../features/schedule/modal/scheduleAtom' ;
18+ import { useSetRecoilState } from 'recoil' ;
1719
1820function ContentCard ( { data, headCount, type, onUnlike, backButtonText } ) {
1921 const {
@@ -32,13 +34,14 @@ function ContentCard({ data, headCount, type, onUnlike, backButtonText }) {
3234 isLiked,
3335 } = data ;
3436
37+ // 로그인 상태 검증
38+ const isLoggedIn = useAuthSession ( ) ;
39+
3540 // state 관리
3641 const [ imageUrl , setImageUrl ] = useState ( img ) ;
37- const [ isHeartActive , setIsHeartActive ] = useState ( isLiked ) ;
42+ const [ isHeartActive , setIsHeartActive ] = useState ( isLoggedIn ? isLiked : false ) ;
3843 const [ isLoginModalOpen , setIsLoginModalOpen ] = useState ( false ) ;
39-
40- // 로그인 상태 검증
41- const isLoggedIn = useAuthSession ( ) ;
44+ const setScheduleModalState = useSetRecoilState ( scheduleModalState ) ;
4245
4346 // navigate
4447 const navigate = useNavigate ( ) ;
@@ -63,12 +66,21 @@ function ContentCard({ data, headCount, type, onUnlike, backButtonText }) {
6366
6467 // 좋아요 상태 관리
6568 useEffect ( ( ) => {
66- setIsHeartActive ( isLiked ) ;
67- console . log ( 'data: ' , data ) ;
68- } , [ isLiked , data ] ) ;
69+ setIsHeartActive ( isLoggedIn ? isLiked : false ) ;
70+ } , [ isLiked , isLoggedIn ] ) ;
6971
7072 return (
71- < ContentWrapper onClick = { ( ) => navigate ( `/theme/${ themeId } ` , { state : { backButtonText } } ) } >
73+ < ContentWrapper
74+ onClick = { ( ) => {
75+ setScheduleModalState ( {
76+ isOpen : false ,
77+ mode : 'add' ,
78+ reservation : null ,
79+ } ) ;
80+
81+ navigate ( `/theme/${ themeId } ` , { state : { backButtonText } } ) ;
82+ } }
83+ >
7284 { /* 이미지 영역 */ }
7385 < ImageSection imgUrl = { imageUrl } >
7486 < LocationTag > { locationName } </ LocationTag >
0 commit comments