add button download template batch disbursement

This commit is contained in:
Wikzyy
2025-05-06 09:47:17 +07:00
parent 3c3ee24f1a
commit 69ebdc31ed
2 changed files with 21 additions and 2 deletions

Binary file not shown.

View File

@ -3,6 +3,7 @@ import { useTransactionContext } from '../hooks/useTransactionContext';
import { Button } from '@/components/ui/button';
import { useCallback, useState, useEffect } from 'react';
import { toast } from 'sonner';
import { toAbsoluteUrl } from '@/utils';
const ListToolbar = () => {
const { table, reload } = useDataGrid();
@ -23,8 +24,8 @@ const ListToolbar = () => {
nextWeek.setDate(today.getDate() + 7);
settrxDate({
from: formatDate(today), // Set 'from' to today
to: formatDate(nextWeek), // Set 'to' to 7 days later
from: formatDate(today), // Set 'from' to today
to: formatDate(nextWeek) // Set 'to' to 7 days later
});
}, []);
@ -37,6 +38,15 @@ const ListToolbar = () => {
}
}, [trxDate, table]);
const handleExportData = () => {
const link = document.createElement('a');
link.href = toAbsoluteUrl('/media/file-templates/batch-sample.xlsx');
link.download = 'upload-batch-template.xlsx';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
useEffect(() => {
if (trxDate.from && trxDate.to) {
handleFilterData();
@ -55,6 +65,15 @@ const ListToolbar = () => {
>
Upload Batch
</Button>
<DefaultTooltip title={'Download Template'} placement={'top'}>
<Button onClick={handleExportData} className="h-7.5" variant={'outline'}>
<img
src={toAbsoluteUrl('/media/file-types/xls.svg')}
className="dark:hidden h-5"
alt="Export to Excel"
/>
</Button>
</DefaultTooltip>
<DefaultTooltip title={'Refresh'} placement={'top'}>
<Button variant="outline" className="h-7.5" onClick={() => reload()}>
<KeenIcon icon="arrows-circle" />