Fe changes

This commit is contained in:
2026-10-16 15:47:23 +05:30
parent 09d86835a2
commit c5a0992b5d
23 changed files with 2715 additions and 89 deletions
@@ -0,0 +1,39 @@
'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<void>
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 (
<>
<Button size="sm" variant="outline" disabled={disabled || busy !== null} onClick={() => run('excel')}>
{busy === 'excel' ? 'Exporting…' : 'Export Excel'}
</Button>
<Button size="sm" variant="outline" disabled={disabled || busy !== null} onClick={() => run('pdf')}>
{busy === 'pdf' ? 'Exporting…' : 'Export PDF'}
</Button>
</>
)
}