import React from "react";
import QuotationCard from "./QuotationCard";

interface Quotation {
  id: number;
  name: string;
  file: string;
  status: string;
}

interface QuotationListProps {
  quotations: Quotation[];
  selectedQuotation: number | null;
  remark: string;
  onSelect: (id: number) => void;
  onRemarkChange: (remark: string) => void;
  onDownload: (file: string) => void;
}

export default function QuotationList({
  quotations,
  selectedQuotation,
  remark,
  onSelect,
  onRemarkChange,
  onDownload,
}: QuotationListProps) {
  if (quotations.length === 0) {
    return (
      <div className="text-center py-8 text-gray-500">
        No quotations available
      </div>
    );
  }

  const approvedQuotation = quotations.find(q => q.status === "Approved");
  const hasApprovedQuotation = !!approvedQuotation;

  return (
    <div className="space-y-4">
      {quotations.map((quote) => (
        <QuotationCard
          key={quote.id}
          id={quote.id}
          name={quote.name}
          file={quote.file}
          status={quote.status}
          isSelected={selectedQuotation === quote.id}
          remark={remark}
          isApproved={quote.status === "Approved"}
          hasApprovedQuotation={hasApprovedQuotation}
          onSelect={onSelect}
          onRemarkChange={onRemarkChange}
          onDownload={onDownload}
        />
      ))}
    </div>
  );
}
