import { useState } from 'react' import { useMutation } from '@tanstack/react-query' import { Download, FileSpreadsheet } from 'lucide-react' import { toast } from 'sonner' import { PageHeader } from '@/components/PageHeader' import { Button } from '@/components/ui/Button' import { Label } from '@/components/ui/Label' import { Select } from '@/components/ui/Select' import { Input } from '@/components/ui/Input' import { api } from '@/lib/api' import { getErrorMessage } from '@/lib/apiError' import { ContractPhase, ContractPhaseLabel } from '@/types/contracts' export function ReportsPage() { const [phase, setPhase] = useState('') const [fromDate, setFromDate] = useState('') const [toDate, setToDate] = useState('') const exportMut = useMutation({ mutationFn: async () => { const params: Record = {} if (phase) params.phase = phase if (fromDate) params.fromDate = fromDate if (toDate) params.toDate = toDate const res = await api.get('/reports/contracts/export', { params, responseType: 'blob' }) const filename = res.headers['content-disposition']?.match(/filename="?([^";]+)"?/)?.[1] ?? 'contracts.xlsx' return { blob: res.data as Blob, filename } }, onSuccess: ({ blob, filename }) => { const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = filename a.click() URL.revokeObjectURL(url) toast.success('Đã tải file') }, onError: err => toast.error(getErrorMessage(err)), }) return (

Xuất danh sách HĐ (.xlsx)

setFromDate(e.target.value)} />
setToDate(e.target.value)} />
Báo cáo khác (Phase 4 iteration 2):
  • HĐ quá hạn SLA theo phase / role
  • Biểu đồ giá trị HĐ theo tháng / dự án
  • Export Approvals history
  • Export từng HĐ ra PDF
) }