Skip to content

Commit

Permalink
Fix: 린트 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
ssumai-kr committed Jul 26, 2024
1 parent d6d2cf6 commit 4789c10
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 28 deletions.
37 changes: 22 additions & 15 deletions components/ActivityDetails/ActivityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,30 @@ export default function ActivityDetails({ id }: ActivityDetailsProps) {
queryFn: () => getActivityInfo({ id }),
});

const addViewedActivity = useCallback((newActivity: ViewedActivityProps) => {
setViewedInfo(prevViewedInfo => {
// 중복되는 항목 찾기
const isDuplicate = prevViewedInfo.some(activity => activity.id === newActivity.id);
let updatedViewedInfo = prevViewedInfo.filter(activity => activity.id !== newActivity.id);

// 새로운 항목 추가
updatedViewedInfo = [newActivity, ...updatedViewedInfo];
const addViewedActivity = useCallback(
(newActivity: ViewedActivityProps) => {
setViewedInfo((prevViewedInfo) => {
// 중복되는 항목 찾기
const isDuplicate = prevViewedInfo.some(
(activity) => activity.id === newActivity.id
);
let updatedViewedInfo = prevViewedInfo.filter(
(activity) => activity.id !== newActivity.id
);

// 10개를 초과할 경우 가장 오래된 항목 삭제
if (updatedViewedInfo.length > 10) {
updatedViewedInfo.pop();
}
// 새로운 항목 추가
updatedViewedInfo = [newActivity, ...updatedViewedInfo];

return updatedViewedInfo;
});
}, [setViewedInfo]);
// 10개를 초과할 경우 가장 오래된 항목 삭제
if (updatedViewedInfo.length > 10) {
updatedViewedInfo.pop();
}

return updatedViewedInfo;
});
},
[setViewedInfo]
);

const {
data: reviewData,
Expand Down
9 changes: 7 additions & 2 deletions components/ViewedActivities/ViewedActivities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,21 @@ function ViewedActivities() {
<div className="font-sans text-[14px] font-[600]">
최근 방문한 체험
</div>
<div className='flex flex-col gap-[10px]'>
<div className="flex flex-col gap-[10px]">
{ViewedActivitiesVlue.map((activity) => (
<ViewedActivity
key={activity.id}
id={activity.id}
bannerImage={activity.bannerImage}
title={activity.title}
/>
))}
</div>
{(ViewedActivitiesVlue.length === 10) && <div className='font-sans text-[10px] font-[600]'>*최근 10개 정보까지 볼 수 있습니다.</div>}
{ViewedActivitiesVlue.length === 10 && (
<div className="font-sans text-[10px] font-[600]">
*최근 10개 정보까지 볼 수 있습니다.
</div>
)}
</div>
)}
</div>
Expand Down
25 changes: 14 additions & 11 deletions components/ViewedActivities/ViewedActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ function ViewedActivity({ id, bannerImage, title }: ViewedActivityProps) {
};

return (
<div className="min-w-[140px] min-h-[80px] rounded bg-gray-200 flex items-center justify-between cursor-pointer block hover:bg-gray-300" onClick={linkToClick}>
<Image
src={bannerImage}
alt="배너이미지"
width={42}
height={40}
className="ml-[10px] min-w-[42px] min-h-[40px] max-w-[42px] max-h-[40px]"
/>
<div className="mr-[10px] font-sans text-[12px] font-[700] w-[70px] h-[38px] line-clamp-2 overflow-hidden">
{title}
</div>
<div
className="min-w-[140px] min-h-[80px] rounded bg-gray-200 flex items-center justify-between cursor-pointer block hover:bg-gray-300"
onClick={linkToClick}
>
<Image
src={bannerImage}
alt="배너이미지"
width={42}
height={40}
className="ml-[10px] min-w-[42px] min-h-[40px] max-w-[42px] max-h-[40px]"
/>
<div className="mr-[10px] font-sans text-[12px] font-[700] w-[70px] h-[38px] line-clamp-2 overflow-hidden">
{title}
</div>
</div>
);
}

Expand Down

0 comments on commit 4789c10

Please sign in to comment.