add button download template batch disbursement
This commit is contained in:
BIN
public/media/file-templates/batch-sample.xlsx
Normal file
BIN
public/media/file-templates/batch-sample.xlsx
Normal file
Binary file not shown.
@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user