Skip to content

Commit 1462660

Browse files
Fix(client): 리마인드 시간 24시간 내에서만 카드 뜨도록 수정 (#171)
* fix: remind time이 24시간 내로 들어오는 아티클만 card ui 띄워주도록 수정 * feat: badge 컴포넌트 leftIcon interface 추가 * feat: remind badge 임시 아이콘 적용 * fix: badge interface 다시 수정 * feat: badge countNum 0 관련 guard 추가
1 parent ee832c5 commit 1462660

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

apps/client/src/pages/remind/Remind.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,18 @@ const Remind = () => {
5555
containerRef,
5656
} = useAnchoredMenu((anchor) => belowOf(anchor, 8));
5757

58-
const articlesToDisplay = data?.pages.flatMap((page) => page.articles) ?? [];
58+
// const articlesToDisplay = data?.pages.flatMap((page) => page.articles) ?? [];
59+
60+
const articlesToDisplay =
61+
data?.pages
62+
.flatMap((page) => page.articles)
63+
.filter((article) => {
64+
const now = new Date().getTime();
65+
const remindTime = new Date(article.remindAt).getTime();
66+
const displayTimeLimit = 24 * 60 * 60 * 1000;
67+
68+
return remindTime > now && remindTime <= now + displayTimeLimit;
69+
}) ?? [];
5970

6071
const getItemTitle = (id: number | null) =>
6172
id == null ? '' : (REMIND_MOCK_DATA.find((d) => d.id === id)?.title ?? '');
@@ -97,22 +108,23 @@ const Remind = () => {
97108
return <div>Loading...</div>;
98109
}
99110

100-
const unreadArticleCount = data?.pages[0]?.unreadArticleCount || 0;
101-
const readArticleCount = data?.pages[0]?.readArticleCount || 0;
111+
// TODO: 임시
112+
// const unreadArticleCount = data?.pages[0]?.unreadArticleCount || 0;
113+
// const readArticleCount = data?.pages[0]?.readArticleCount || 0;
102114

103115
return (
104116
<div className="flex flex-col py-[5.2rem] pl-[8rem] pr-[5rem]">
105117
<p className="head3">리마인드</p>
106118
<div className="mt-[3rem] flex gap-[2.4rem]">
107119
<Badge
108120
text="안 읽음"
109-
countNum={unreadArticleCount}
121+
// countNum={unreadArticleCount}
110122
onClick={() => handleBadgeClick('notRead')}
111123
isActive={activeBadge === 'notRead'}
112124
/>
113125
<Badge
114126
text="읽음"
115-
countNum={readArticleCount}
127+
// countNum={readArticleCount}
116128
onClick={() => handleBadgeClick('read')}
117129
isActive={activeBadge === 'read'}
118130
/>

packages/design-system/src/components/badge/Badge.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ const Badge = ({ text, countNum, isActive, onClick }: BadgeProps) => {
4242
<span className={BadgeTxtStyleVariants({ active: isActive })}>
4343
{text}
4444
</span>
45-
<span className={BadgeStyleVariants({ active: isActive })}>
46-
{countNum}
47-
</span>
45+
46+
{typeof countNum === 'number' && countNum >= 0 && (
47+
<span className={BadgeStyleVariants({ active: isActive })}>
48+
{countNum}
49+
</span>
50+
)}
4851
</div>
4952
);
5053
};

packages/design-system/src/components/card/RemindCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const RemindCard = ({
2828
const [displayTime, setDisplayTime] = useState('');
2929

3030
useEffect(() => {
31-
const endTime = new Date(timeRemaining).getTime() + 24 * 60 * 60 * 1000;
31+
// const endTime = new Date(timeRemaining).getTime() + 24 * 60 * 60 * 1000;
32+
const endTime = new Date(timeRemaining).getTime();
3233

3334
const updateRemainingTime = () => {
3435
const now = new Date().getTime();

0 commit comments

Comments
 (0)