-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 요일 헤더에 자동 날짜 표시 추가 #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ interface HostSchedule extends PublicSchedule { | |
| commonSlots: TimeSlot[]; | ||
| } | ||
|
|
||
| const DAY_LABELS: Record<DayCode, string> = { | ||
| const DAY_LABELS: Record<string, string> = { | ||
| MON: "월요일", | ||
| TUE: "화요일", | ||
| WED: "수요일", | ||
|
|
@@ -61,6 +61,26 @@ const DAY_LABELS: Record<DayCode, string> = { | |
| SUN: "일요일", | ||
| }; | ||
|
|
||
| const DAY_CODE_TO_JS_DAY: Record<string, number> = { | ||
| SUN: 0, | ||
| MON: 1, | ||
| TUE: 2, | ||
| WED: 3, | ||
| THU: 4, | ||
| FRI: 5, | ||
| SAT: 6, | ||
| }; | ||
|
|
||
| function formatDayWithDate(dayCode: string): string { | ||
| const now = new Date(); | ||
| const diff = (DAY_CODE_TO_JS_DAY[dayCode] - now.getDay() + 7) % 7; | ||
| const target = new Date(now); | ||
| target.setDate(now.getDate() + diff); | ||
| const m = target.getMonth() + 1; | ||
| const d = target.getDate(); | ||
| return `${DAY_LABELS[dayCode] ?? dayCode} ${m}/${d}`; | ||
| } | ||
|
|
||
| export function ScheduleRoomClient({ | ||
| scheduleId, | ||
| hostToken, | ||
|
|
@@ -295,7 +315,7 @@ export function ScheduleRoomClient({ | |
| slots.push({ | ||
| key: `${day}-${hour}`, | ||
| slot: { day, startHour: hour, endHour: hour + 1 }, | ||
| label: `${DAY_LABELS[day]} ${formatHour(hour)}-${formatHour(hour + 1)}`, | ||
| label: `${formatDayWithDate(day)} ${formatHour(hour)}-${formatHour(hour + 1)}`, | ||
| }); | ||
| } | ||
| } | ||
|
|
@@ -405,7 +425,7 @@ export function ScheduleRoomClient({ | |
| ); | ||
| return; | ||
| } | ||
| if (!isImage && file.size > 100 * 1024) { | ||
| if (!isIcs && file.size > 100 * 1024) { | ||
| setImportMessage("ICS 파일 크기는 100KB 이하여야 합니다."); | ||
| return; | ||
| } | ||
|
Comment on lines
+428
to
431
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# 다른 파일의 ICS 검증 로직과 일관성 확인
rg -n "100.*1024|100KB" --type ts -C 3 | head -80Repository: Siul49/moim Length of output: 2152 🏁 Script executed: sed -n '420,435p' src/app/schedule/[id]/ScheduleRoomClient.tsxRepository: Siul49/moim Length of output: 487 조건 반전 버그 — 이미지 파일에 ICS 크기 제한 메시지 표시 라인 428의
🐛 조건 수정- if (!isIcs && file.size > 100 * 1024) {
+ if (isIcs && file.size > 100 * 1024) {
setImportMessage("ICS 파일 크기는 100KB 이하여야 합니다.");
return;
}🤖 Prompt for AI Agents |
||
|
|
@@ -652,7 +672,7 @@ export function ScheduleRoomClient({ | |
| key={day} | ||
| className="flex h-8 items-center justify-center pb-2 text-center text-sm font-bold text-brand-purple" | ||
| > | ||
| {DAY_LABELS[day]} | ||
| {formatDayWithDate(day)} | ||
| </div> | ||
| ))} | ||
|
|
||
|
|
@@ -1130,7 +1150,7 @@ function HostResultPanel({ | |
| }, [schedule.candidateStartHour, schedule.candidateEndHour]); | ||
|
|
||
| const heatmapDays = useMemo(() => { | ||
| return schedule.candidateDays.map((d) => DAY_LABELS[d] || d); | ||
| return schedule.candidateDays.map((d) => formatDayWithDate(d)); | ||
| }, [schedule.candidateDays]); | ||
|
|
||
| const heatmapColors = useMemo(() => { | ||
|
|
@@ -1446,16 +1466,6 @@ function HostResultPanel({ | |
| ); | ||
| } | ||
|
|
||
| const DAY_CODE_TO_JS_DAY: Record<DayCode, number> = { | ||
| SUN: 0, | ||
| MON: 1, | ||
| TUE: 2, | ||
| WED: 3, | ||
| THU: 4, | ||
| FRI: 5, | ||
| SAT: 6, | ||
| }; | ||
|
|
||
| // 확정 슬롯은 요일 기반({day,startHour,endHour})이므로, | ||
| // 다가오는 해당 요일의 실제 날짜로 환산해 캘린더 일정 start/end를 만든다. | ||
| function nextOccurrence(slot: TimeSlot): { start: Date; end: Date } { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
formatDayWithDate에서 잘못된 dayCode 입력 시 NaN 날짜 생성 가능DAY_CODE_TO_JS_DAY[dayCode]가undefined를 반환하면diff가NaN이 되어 잘못된 날짜가 표시된다. 현재 호출부가 모두DayCode[]를 사용하므로 런타임 위험은 낮으나, 타입이string으로 완화된 만큼 방어 코드가 필요하다.♻️ 방어 코드 추가 제안
function formatDayWithDate(dayCode: string): string { + const jsDay = DAY_CODE_TO_JS_DAY[dayCode]; + if (jsDay === undefined) { + return DAY_LABELS[dayCode] ?? dayCode; + } const now = new Date(); - const diff = (DAY_CODE_TO_JS_DAY[dayCode] - now.getDay() + 7) % 7; + const diff = (jsDay - now.getDay() + 7) % 7; const target = new Date(now); target.setDate(now.getDate() + diff); const m = target.getMonth() + 1; const d = target.getDate(); return `${DAY_LABELS[dayCode] ?? dayCode} ${m}/${d}`; }🤖 Prompt for AI Agents