import { Download } from "lucide-react";

interface ExportCsvLinkProps {
  /** URL endpoint export, mis. `/api/admin/export/refunds`. */
  href: string;
  /** Query string current filter (tanpa leading `?`). */
  query?: string;
  label?: string;
}

/**
 * Tombol download CSV — anchor biasa supaya browser tangani download via
 * `Content-Disposition: attachment` header dari server.
 */
export function ExportCsvLink({
  href,
  query,
  label = "Export CSV",
}: ExportCsvLinkProps) {
  const url = query ? `${href}?${query}` : href;
  return (
    <a
      href={url}
      className="inline-flex items-center gap-1.5 rounded-xl border border-neutral-200 bg-white px-3 py-1.5 text-xs font-semibold text-neutral-700 hover:bg-neutral-50"
      download
    >
      <Download size={16} strokeWidth={2} aria-hidden />
      <span>{label}</span>
    </a>
  );
}
