Skip to content

Commit 1218fd9

Browse files
authored
Merge pull request #418 from code-zero-to-one/refactor/one-to-one-2
fix: 명예의 전당 MVP 주차 라벨 정리
2 parents 730529f + f932a16 commit 1218fd9

3 files changed

Lines changed: 31 additions & 41 deletions

File tree

src/components/common/modals/study-review-modal.tsx

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ export default function StudyReviewModal({
8181
handleDismiss();
8282
};
8383

84+
const handleToggleHideForOneHour = () => {
85+
const nextHideForOneHour = !hideForOneHour;
86+
87+
setHideForOneHour(nextHideForOneHour);
88+
89+
if (nextHideForOneHour) {
90+
setHideForever(false);
91+
}
92+
};
93+
94+
const handleToggleHideForever = () => {
95+
const nextHideForever = !hideForever;
96+
97+
setHideForever(nextHideForever);
98+
99+
if (nextHideForever) {
100+
setHideForOneHour(false);
101+
}
102+
};
103+
84104
return (
85105
<Modal.Root open={open} onOpenChange={handleOpenChange}>
86106
<Modal.Portal>
@@ -110,26 +130,8 @@ export default function StudyReviewModal({
110130
onSubmitSuccessClose={() => onOpenChange(false)}
111131
hideForOneHour={hideForOneHour}
112132
hideForever={hideForever}
113-
onToggleHideForOneHour={() => {
114-
setHideForOneHour((prev) => {
115-
const next = !prev;
116-
if (next) {
117-
setHideForever(false);
118-
}
119-
120-
return next;
121-
});
122-
}}
123-
onToggleHideForever={() => {
124-
setHideForever((prev) => {
125-
const next = !prev;
126-
if (next) {
127-
setHideForOneHour(false);
128-
}
129-
130-
return next;
131-
});
132-
}}
133+
onToggleHideForOneHour={handleToggleHideForOneHour}
134+
onToggleHideForever={handleToggleHideForever}
133135
/>
134136
</Modal.Content>
135137
</Modal.Portal>

src/components/hall-of-fame/hall-of-fame-mvp-section.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ interface HallOfFameMvpSectionProps {
1212
export default function HallOfFameMvpSection({
1313
team,
1414
}: HallOfFameMvpSectionProps) {
15+
const weekLabel = team?.weekDate?.trim();
16+
1517
return (
1618
<div className="flex flex-col gap-300">
1719
<h3 className="font-display-headings6 text-text-strong flex items-center gap-100">
1820
<Users className="text-text-information h-5 w-5" />
19-
저번 주 스터디 MVP 팀
21+
{weekLabel ? `${weekLabel} 스터디 MVP 팀` : '최근 스터디 MVP 팀'}
2022
</h3>
2123

2224
{team ? (
2325
<MVPTeamCard team={team} className="flex-1" />
2426
) : (
2527
<div className="bg-background-default border-border-subtle rounded-200 flex h-[400px] items-center justify-center border">
2628
<p className="font-designer-14m text-text-subtle">
27-
이번 주 MVP 팀이 없습니다.
29+
최근 MVP 팀이 없습니다.
2830
</p>
2931
</div>
3032
)}

src/components/hall-of-fame/mvp-team-card.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,7 @@ interface MVPTeamCardProps {
1414
}
1515

1616
export default function MVPTeamCard({ team, className }: MVPTeamCardProps) {
17-
const weekLabel = (() => {
18-
const dateSource = team.weekDate || team.weekStartDate;
19-
if (!dateSource) return 'MVP 팀';
20-
21-
const date = new Date(dateSource);
22-
if (Number.isNaN(date.getTime())) return 'MVP 팀';
23-
24-
const firstDayOfMonth = new Date(
25-
date.getFullYear(),
26-
date.getMonth(),
27-
1,
28-
).getDay();
29-
const weekOfMonth =
30-
Math.floor((date.getDate() + firstDayOfMonth - 1) / 7) + 1;
31-
32-
return `${date.getMonth() + 1}${weekOfMonth}주차 MVP 팀`;
33-
})();
17+
const weekLabel = team.weekDate?.trim();
3418

3519
return (
3620
<div
@@ -53,7 +37,9 @@ export default function MVPTeamCard({ team, className }: MVPTeamCardProps) {
5337
trigger={
5438
<button
5539
type="button"
56-
aria-label="저번 주 MVP 팀 안내"
40+
aria-label={
41+
weekLabel ? `${weekLabel} MVP 팀 안내` : '최근 MVP 팀 안내'
42+
}
5743
className="border-border-subtle text-text-strong bg-background-default shadow-1 font-designer-24b flex h-600 w-600 items-center justify-center rounded-full border leading-none"
5844
>
5945
?
@@ -65,7 +51,7 @@ export default function MVPTeamCard({ team, className }: MVPTeamCardProps) {
6551
<div className="relative z-10 flex h-full flex-col items-center justify-center gap-400 text-center">
6652
<div className="flex flex-col items-center gap-100">
6753
<span className="bg-fill-warning-subtle-default text-text-warning font-designer-12b border-border-warning-subtle rounded-[9999px] border px-150 py-50">
68-
{weekLabel}
54+
{weekLabel || '최근 MVP 팀'}
6955
</span>
7056
<h3 className="font-display-headings5 text-text-strong">
7157
최고의 스터디 메이트

0 commit comments

Comments
 (0)