'use client'; import type { CalendarEventView } from '@/services/ScheduleService'; import { eventsOnDay, eventHour, formatTime, getDayHours, toISODate, } from '@/lib/calendar/grid'; import { SOURCE_COLORS, SOURCE_CHIP_BORDER, WEEKDAY_LABELS, } from '@/components/calendar/sourceColors'; /** * 日表示(時間グリッド)。0:00〜23:00 を1時間刻みで表示し、 * 時刻付きイベントを該当時刻行に、終日(日付のみ)イベントを上部に配置する。 */ export function DayView({ day, events, todayKey, onSelectDate, }: { day: Date; events: CalendarEventView[]; todayKey: string; onSelectDate: (dateKey: string) => void; }) { const key = toISODate(day); const dayEvents = eventsOnDay(events, key); const allDay = dayEvents.filter((e) => eventHour(e.startAt) === null); const timed = dayEvents.filter((e) => eventHour(e.startAt) !== null); const hours = getDayHours(); const isToday = key === todayKey; return (
{isToday && ( 今日 )}
{allDay.length > 0 && (

終日

{allDay.map((e) => ( ))}
)}
{hours.map((h) => { const hourEvents = timed.filter((e) => eventHour(e.startAt) === h); return (
{String(h).padStart(2, '0')}:00
{hourEvents.map((e) => ( ))}
); })}
); }