'use client';

import { Receipt } from 'lucide-react';
import { AmountCardItem, CheckPointItem, CollapsibleDashboardCard } from '../components';
import type { MonthlyExpenseData } from '../types';

interface MonthlyExpenseSectionProps {
  data: MonthlyExpenseData;
  onCardClick?: (cardId: string) => void;
}

export function MonthlyExpenseSection({ data, onCardClick }: MonthlyExpenseSectionProps) {
  return (
    <CollapsibleDashboardCard
      icon={<Receipt style={{ color: '#ffffff' }} className="h-5 w-5" />}
      title="당월 예상 지출 내역"
      subtitle="이달 예상 지출 정보"
    >
      <div className="grid grid-cols-1 xs:grid-cols-2 md:grid-cols-4 gap-3 xs:gap-4 mb-4">
        {data.cards.map((card) => (
          <AmountCardItem
            key={card.id}
            card={card}
            onClick={onCardClick ? () => onCardClick(card.id) : undefined}
          />
        ))}
      </div>

      {data.checkPoints.length > 0 && (
        <div className="border-t pt-4 space-y-1">
          {data.checkPoints.map((cp) => (
            <CheckPointItem key={cp.id} checkpoint={cp} />
          ))}
        </div>
      )}
    </CollapsibleDashboardCard>
  );
}
