// frontend/components/calendar/MonthView.tsx — 월 뷰 (실제 날짜 기반, 셀당 이벤트 ≤3 + +N개 더) "use client"; import type { MouseEvent } from "react"; import { dayNum, monthCells, toMin } from "@/lib/calendar/time"; import type { CalEvent, Calendar } from "@/lib/calendar/types"; export function MonthView({ events, calMap, monthRef, weekdays, todayDate, onOpen, onSelDay, }: { events: CalEvent[]; calMap: Record; monthRef: string; // 보여줄 달(ISO) weekdays: string[]; todayDate: string; onOpen: (ev: CalEvent, e: MouseEvent) => void; onSelDay: (iso: string) => void; }) { const byDate: Record = {}; events.forEach((e) => { (byDate[e.date] = byDate[e.date] || []).push(e); }); Object.values(byDate).forEach((a) => a.sort((x, y) => toMin(x.start) - toMin(y.start))); const cells = monthCells(monthRef); return (
{weekdays.map((w, i) => (
{w}
))}
{cells.map((c) => { const evs = c.inMonth ? byDate[c.date] || [] : []; return (
c.inMonth && onSelDay(c.date)} >
{dayNum(c.date)}
{evs.slice(0, 3).map((ev) => (
{ e.stopPropagation(); onOpen(ev, e); }} > {ev.start || "종일"} {ev.title}
))} {evs.length > 3 &&
+{evs.length - 3}개 더
}
); })}
); }