import React, { useRef } from 'react'; import { motion } from 'framer-motion'; import { format, addDays } from 'date-fns'; import DraggableEvent from './DraggableEvent'; import { Event } from '../types'; interface DayColumnProps { date: Date; events: Event[]; isMobile: boolean; index: number; onEventClick: (eventData: { event: Event; date: string }) => void; onDragStart: () => void; onDragEnd: () => void; handleEventMove: (eventId: string, newDate: Date) => void; onDayChange: (dir: 'left' | 'right') => void; isClient: boolean; } const DayColumn: React.FC = ({ date, events, isMobile, index, onEventClick, onDragStart, onDragEnd, handleEventMove, onDayChange, isClient }) => { const columnRef = useRef(null); const sortedEvents = [...events].sort((a, b) => { const timeA = new Date(a.time).getTime(); const timeB = new Date(b.time).getTime(); return timeA - timeB; }); const handleMove = (dir: 'up' | 'down') => { // ... existing code ... }; return (
{format(date, 'EEE, MMM d')}
{sortedEvents .filter(event => event && event.id) .map((event, index) => ( onEventClick({ event: eventData.event, date: eventData.date })} onDragStart={() => onDragStart()} onDragEnd={() => onDragEnd()} onDayChange={(dir) => { onDayChange(dir); const newDate = addDays(date, dir === 'left' ? -1 : 1); handleEventMove(event.id, newDate); }} isClient={isClient} /> ))}
); }; export default DayColumn;