-
-
Notifications
You must be signed in to change notification settings - Fork 347
Expand file tree
/
Copy pathAdminDownloadButton.tsx
More file actions
34 lines (28 loc) · 978 Bytes
/
AdminDownloadButton.tsx
File metadata and controls
34 lines (28 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { FC } from 'react';
import { components } from 'tg.service/billingApiSchema.generated';
import { useBillingApiMutation } from 'tg.service/http/useQueryApi';
import { useInvoicePdfDownload } from '../../Invoices/useInvoicePdfDownload';
import { PdfDownloadButton } from '../../Invoices/PdfDownloadButton';
type AdminDownloadButtonProps = {
invoice: components['schemas']['InvoiceModel'];
};
export const AdminDownloadButton: FC<AdminDownloadButtonProps> = ({
invoice,
}) => {
const { onSuccess } = useInvoicePdfDownload(invoice);
const pdfMutation = useBillingApiMutation({
url: '/v2/administration/billing/invoices/{invoiceId}/pdf',
method: 'get',
fetchOptions: { rawResponse: true },
});
const onDownload = () => {
pdfMutation.mutate({ path: { invoiceId: invoice.id } }, { onSuccess });
};
return (
<PdfDownloadButton
invoice={invoice}
onDownload={onDownload}
isLoading={pdfMutation.isLoading}
/>
);
};