[WIP] Update Dashboard Claim Final LOG
This commit is contained in:
@@ -174,10 +174,49 @@ export default function ClaimsCreateUpdate() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleDownloadFinalLog = () => {
|
||||
enqueueSnackbar("Gagal Download Final LOG", { variant: 'error' })
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Initial LOG
|
||||
const [loadingLog, setLoadingLog] = useState(false)
|
||||
|
||||
const handleDownloadLog = (claim_id) => {
|
||||
setLoadingLog(true);
|
||||
axios
|
||||
.post(`generate-log/${claim_id}`, {
|
||||
responseType: 'blob',
|
||||
})
|
||||
.then((response) => {
|
||||
window.open(URL.createObjectURL(response.data));
|
||||
setLoadingLog(false);
|
||||
setOpenDialog(false);
|
||||
})
|
||||
.catch((response) => {
|
||||
enqueueSnackbar(response.message, { variant: 'error' });
|
||||
setLoadingLog(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------
|
||||
// Final LOG
|
||||
const [loadingFinalLog, setLoadingFinalLog] = useState(false)
|
||||
const handleDownloadFinalLog = (claim_id) => {
|
||||
setLoadingFinalLog(true);
|
||||
axios
|
||||
.get(`final-log/${claim_id}`, {
|
||||
responseType: 'blob',
|
||||
})
|
||||
.then((response) => {
|
||||
window.open(URL.createObjectURL(response.data));
|
||||
setLoadingFinalLog(false);
|
||||
})
|
||||
.catch((response) => {
|
||||
enqueueSnackbar(response.message, { variant: 'error' });
|
||||
setLoadingFinalLog(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
axios.get('/claims/' + id).then(({ data }) => {
|
||||
const claim = data.data;
|
||||
@@ -247,14 +286,14 @@ export default function ClaimsCreateUpdate() {
|
||||
</Stack>
|
||||
|
||||
<Paper variant="outlined" sx={{ background: '#f4f6f8', p: 2, marginY: 2 }}>
|
||||
<Stack direction="row" justifyContent="space-between">
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
||||
<Typography>Status : {currentClaim?.status}</Typography>
|
||||
{ currentClaim?.status == 'approved' && (
|
||||
<LoadingButton
|
||||
loading={false}
|
||||
loading={loadingFinalLog}
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
handleDownloadFinalLog();
|
||||
handleDownloadFinalLog(currentClaim.id);
|
||||
}}
|
||||
>
|
||||
Download Final LOG
|
||||
|
||||
Reference in New Issue
Block a user