'use client';

import { cn } from '@/components/ui/utils';
import type { ScheduleEvent } from './types';

interface MorePopoverProps {
  date: Date;
  events: ScheduleEvent[];
  hiddenCount: number;
  onEventClick: (event: ScheduleEvent) => void;
  onDateClick?: (date: Date) => void;
}

/**
 * 더보기 버튼 컴포넌트
 * - +N 버튼 렌더링
 * - 클릭 시 해당 날짜 선택 (테이블 필터링)
 */
export function MorePopover({
  date,
  hiddenCount,
  onDateClick,
}: MorePopoverProps) {
  if (hiddenCount <= 0) return null;

  const handleClick = (e: React.MouseEvent) => {
    e.stopPropagation();
    // 날짜 선택 → 테이블 필터링
    onDateClick?.(date);
  };

  return (
    <button
      type="button"
      className={cn(
        'text-xs font-medium text-muted-foreground',
        'hover:text-primary hover:underline',
        'transition-colors cursor-pointer'
      )}
      onClick={handleClick}
    >
      +{hiddenCount} 더보기
    </button>
  );
}