Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions umc-master/src/pages/main/components/TipsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AnimatePresence, motion } from 'framer-motion';
import { useSearchList } from '@apis/queries/useSearchList';
import BigCard from '@components/Card/BigCard';
import SkeletonBigCard from '@components/Skeleton/SkeletonBigCard';

import { recentStore } from '@store/recentStore';
interface TipsSectionProps {
title?: string;
showArrows?: boolean;
Expand Down Expand Up @@ -146,8 +146,11 @@ const TipsSection: React.FC<TipsSectionProps> = ({

if (isError) return <div>Something went wrong...</div>; // 에러 발생 시 표시

const handleCardClick = (id: number) => {
navigate(`/save-tip/${id}`);
const { addRecentTip } = recentStore(); // Zustand 상태 가져오기

const handleCardClick = (tip: TipItem) => {
addRecentTip(tip); // 최근 본 팁으로 저장
navigate(`/save-tip/${tip.tipId}`); // 상세 페이지로 이동
};

const handleSlide = (direction: number) => {
Expand Down Expand Up @@ -212,7 +215,7 @@ const TipsSection: React.FC<TipsSectionProps> = ({
likes={item.likesCount || 0}
bookmarks={item.savesCount || 0}
date={item.createdAt?.slice(0, 10) || ''}
onClick={() => handleCardClick(item.tipId)}
onClick={() => handleCardClick(item)}
/>
))}
</CardsWrapper>
Expand Down
5 changes: 3 additions & 2 deletions umc-master/src/pages/mypage/components/RecentTips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Typography from '@components/common/typography';
import { useNavigate } from 'react-router-dom';
import { recentStore } from '@store/recentStore';
import { useEffect } from 'react';
import dummyImage from '@assets/dummyImage/dummy.jpeg';

const RecentTips: React.FC = () => {
const theme = useTheme();
Expand Down Expand Up @@ -33,11 +34,11 @@ const RecentTips: React.FC = () => {
{recentTips.map((item) => (
<Card
key={item.tipId}
image={item.imageUrls[0].media_url}
image={item.imageUrls?.[0]?.media_url || dummyImage}
text={item.title}
likes={item.likesCount || 0}
bookmarks={item.savesCount || 0}
date={item.createdAt || ''}
date={item.createdAt?.slice(0, 10) || ''}
onClick={() => handleCardClick(String(item.tipId))}
/>
))}
Expand Down