'use client' import { useState } from 'react' import { Button } from '@/components/ui/button' import { toast } from '@/components/ui/toast' import { getApiError } from '@/lib/api/index' interface ExportButtonsProps { /** Runs the export for the chosen format; fetch the full filtered data inside. */ onExport: (format: 'excel' | 'pdf') => Promise disabled?: boolean } export function ExportButtons({ onExport, disabled }: ExportButtonsProps) { const [busy, setBusy] = useState<'excel' | 'pdf' | null>(null) async function run(format: 'excel' | 'pdf') { setBusy(format) try { await onExport(format) } catch (err) { toast.add({ title: 'Export failed', description: getApiError(err), type: 'error' }) } finally { setBusy(null) } } return ( <> ) }