Fix Download LOG

This commit is contained in:
R
2023-02-15 12:50:46 +07:00
parent 5d4033a9ca
commit a5db01bd25
5 changed files with 56 additions and 8 deletions

View File

@@ -39,6 +39,7 @@ import { useSearchParams } from 'react-router-dom';
// import { UserCurrentCorporateContext } from '@/contexts/UserCurrentCorporate';
import { fSplit } from '@/utils/formatNumber';
import { Chip } from '@mui/material';
import { enqueueSnackbar } from 'notistack';
/* ---------------------------------- types --------------------------------- */
type PaginationTableProps = {
@@ -307,6 +308,26 @@ export default function TableList(props: any) {
})();
}, [appliedParams, searchParams, order, orderBy, setSearchParams]);
// -----------------------------------------------------------------
// Download LOG
function handleDownloadLog(claimRequest) {
axios.get(`claim-requests/${claimRequest.id}/log`, {
responseType: 'blob'
})
.then((response) => {
window.open(URL.createObjectURL(response.data));
// setLoadingLog(false);
})
// .then((blobFile) => {
// new File([blobFile], 'asdads.pdf', { type: blobFile.type })
// setLoadingLog(false);
// })
.catch((response) => {
enqueueSnackbar(response.message, {variant: 'error'})
// setLoadingLog(false);
})
}
return (
<Card>
<Grid container>
@@ -395,7 +416,7 @@ export default function TableList(props: any) {
<TableCell align="center">{row.member?.full_name ?? ''}</TableCell>
<TableCell align="center">{row.submission_date}</TableCell>
<TableCell align="right">
{row.log_url ? (
{row.status == 'approved' ? (
<Button
sx={{
backgroundColor: palette.light.grey[400],
@@ -406,6 +427,7 @@ export default function TableList(props: any) {
color: palette.dark.success.darker,
},
}}
onClick={() => {handleDownloadLog(row)}}
>
Download LOG
</Button>