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 { Button } from '@/components/ui/button';
|
||||||
import { useCallback, useState, useEffect } from 'react';
|
import { useCallback, useState, useEffect } from 'react';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
|
import { toAbsoluteUrl } from '@/utils';
|
||||||
|
|
||||||
const ListToolbar = () => {
|
const ListToolbar = () => {
|
||||||
const { table, reload } = useDataGrid();
|
const { table, reload } = useDataGrid();
|
||||||
@ -24,7 +25,7 @@ const ListToolbar = () => {
|
|||||||
|
|
||||||
settrxDate({
|
settrxDate({
|
||||||
from: formatDate(today), // Set 'from' to today
|
from: formatDate(today), // Set 'from' to today
|
||||||
to: formatDate(nextWeek), // Set 'to' to 7 days later
|
to: formatDate(nextWeek) // Set 'to' to 7 days later
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -37,6 +38,15 @@ const ListToolbar = () => {
|
|||||||
}
|
}
|
||||||
}, [trxDate, table]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
if (trxDate.from && trxDate.to) {
|
if (trxDate.from && trxDate.to) {
|
||||||
handleFilterData();
|
handleFilterData();
|
||||||
@ -55,6 +65,15 @@ const ListToolbar = () => {
|
|||||||
>
|
>
|
||||||
Upload Batch
|
Upload Batch
|
||||||
</Button>
|
</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'}>
|
<DefaultTooltip title={'Refresh'} placement={'top'}>
|
||||||
<Button variant="outline" className="h-7.5" onClick={() => reload()}>
|
<Button variant="outline" className="h-7.5" onClick={() => reload()}>
|
||||||
<KeenIcon icon="arrows-circle" />
|
<KeenIcon icon="arrows-circle" />
|
||||||
|
|||||||
Reference in New Issue
Block a user