tambah loading export
This commit is contained in:
@@ -126,5 +126,6 @@ export type TableListProps<DataType> = {
|
|||||||
status: string;
|
status: string;
|
||||||
handleExportReport: (event: FormEvent<HTMLFormElement>) => void;
|
handleExportReport: (event: FormEvent<HTMLFormElement>) => void;
|
||||||
};
|
};
|
||||||
|
exportLoading?: boolean;
|
||||||
};
|
};
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import BaseTablePagination from './BaseTablePagination';
|
|||||||
import { Download, Search as SearchIcon } from '@mui/icons-material';
|
import { Download, Search as SearchIcon } from '@mui/icons-material';
|
||||||
/* ---------------------------------- types --------------------------------- */
|
/* ---------------------------------- types --------------------------------- */
|
||||||
import { DivisionDataProps, StatusDataProps, TableListProps } from '../@types/table';
|
import { DivisionDataProps, StatusDataProps, TableListProps } from '../@types/table';
|
||||||
|
import { LoadingButton } from '@mui/lab';
|
||||||
|
|
||||||
export default function Table<T>({
|
export default function Table<T>({
|
||||||
headCells,
|
headCells,
|
||||||
@@ -42,6 +43,7 @@ export default function Table<T>({
|
|||||||
filterEndDate,
|
filterEndDate,
|
||||||
searchs,
|
searchs,
|
||||||
exportReport,
|
exportReport,
|
||||||
|
exportLoading,
|
||||||
}: TableListProps<T>) {
|
}: TableListProps<T>) {
|
||||||
/* ------------------------------- handle sort ------------------------------ */
|
/* ------------------------------- handle sort ------------------------------ */
|
||||||
const handleRequestSort = async (event: React.MouseEvent<unknown>, property: string) => {
|
const handleRequestSort = async (event: React.MouseEvent<unknown>, property: string) => {
|
||||||
@@ -308,16 +310,18 @@ export default function Table<T>({
|
|||||||
{exportReport && exportReport.useExport ? (
|
{exportReport && exportReport.useExport ? (
|
||||||
<Grid item xs={12} lg={2} xl={2}>
|
<Grid item xs={12} lg={2} xl={2}>
|
||||||
<FormControl fullWidth>
|
<FormControl fullWidth>
|
||||||
<Button
|
<LoadingButton
|
||||||
|
id="upload-button"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
sx={{ p: 2 }}
|
startIcon={<Download />}
|
||||||
|
sx={{ p: 1.8 }}
|
||||||
onClick={() => exportReport.handleExportReport()}
|
onClick={() => exportReport.handleExportReport()}
|
||||||
|
loading={exportLoading}
|
||||||
>
|
>
|
||||||
<Download />
|
|
||||||
<Typography variant="inherit" sx={{ marginLeft: 1 }}>
|
<Typography variant="inherit" sx={{ marginLeft: 1 }}>
|
||||||
Export
|
Export
|
||||||
</Typography>
|
</Typography>
|
||||||
</Button>
|
</LoadingButton>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ export default function List() {
|
|||||||
const handleExportReport = async () => {
|
const handleExportReport = async () => {
|
||||||
|
|
||||||
var filter = Object.fromEntries([...searchParams.entries()]);
|
var filter = Object.fromEntries([...searchParams.entries()]);
|
||||||
|
setIsLoading(true)
|
||||||
await axios
|
await axios
|
||||||
.get(corporateValue + '/claims/exportAlrmCenter/'+(startDateValue ? startDateValue : 'all')+'/'+(endDateValue ? endDateValue : 'all'), { params: filter })
|
.get(corporateValue + '/claims/exportAlrmCenter/'+(startDateValue ? startDateValue : 'all')+'/'+(endDateValue ? endDateValue : 'all'), { params: filter })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -202,6 +202,7 @@ export default function List() {
|
|||||||
variant: 'success',
|
variant: 'success',
|
||||||
anchorOrigin: { horizontal: 'right', vertical: 'top' },
|
anchorOrigin: { horizontal: 'right', vertical: 'top' },
|
||||||
});
|
});
|
||||||
|
setIsLoading(false)
|
||||||
|
|
||||||
document.location.href = res.data.data.file_url;
|
document.location.href = res.data.data.file_url;
|
||||||
})
|
})
|
||||||
@@ -210,6 +211,7 @@ export default function List() {
|
|||||||
variant: 'error',
|
variant: 'error',
|
||||||
anchorOrigin: { horizontal: 'right', vertical: 'top' },
|
anchorOrigin: { horizontal: 'right', vertical: 'top' },
|
||||||
})
|
})
|
||||||
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const exportReport = {
|
const exportReport = {
|
||||||
@@ -332,6 +334,7 @@ export default function List() {
|
|||||||
filterStartDate={filterStartDate}
|
filterStartDate={filterStartDate}
|
||||||
filterEndDate={filterEndDate}
|
filterEndDate={filterEndDate}
|
||||||
exportReport={exportReport}
|
exportReport={exportReport}
|
||||||
|
exportLoading={isLoading}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user