"use client";

import { Button } from "@/components/ui/button";
import { Download, FileSpreadsheet } from "lucide-react";
import { exportToCSV, exportToExcel, type ExportRow } from "@/lib/utils/csv";

interface ExportButtonsProps {
  rows: ExportRow[];
  filename: string;
  disabled?: boolean;
  summary?: string;
}

export function ExportButtons({ rows, filename, disabled, summary }: ExportButtonsProps) {
  return (
    <div className="flex items-center gap-3 flex-wrap">
      {summary && <span className="text-sm text-gray-400">{summary}</span>}
      <Button
        variant="outline"
        size="sm"
        disabled={disabled || rows.length === 0}
        onClick={() => exportToCSV(rows, `${filename}.csv`)}
        className="border-[#2e2e3e] hover:border-blue-500/50 hover:bg-blue-500/5 text-gray-300"
      >
        <Download className="w-4 h-4 mr-1.5" /> CSV herunterladen
      </Button>
      <Button
        variant="outline"
        size="sm"
        disabled={disabled || rows.length === 0}
        onClick={() => exportToExcel(rows, `${filename}.xlsx`)}
        className="border-[#2e2e3e] hover:border-purple-500/50 hover:bg-purple-500/5 text-gray-300"
      >
        <FileSpreadsheet className="w-4 h-4 mr-1.5" /> Excel herunterladen
      </Button>
    </div>
  );
}
