[WIP] Update Dashboard Claim Final LOG

This commit is contained in:
R
2023-03-08 01:53:16 +07:00
parent ed96878dda
commit b587178c85
14 changed files with 1138 additions and 288 deletions

View File

@@ -31,6 +31,9 @@ import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/
import DataTable from '../../components/LaravelTable';
import { fCurrency } from '../../utils/formatNumber';
import EditRoundedIcon from '@mui/icons-material/EditRounded';
import { Chip } from '@mui/material';
import Iconify from '@/components/Iconify';
import { enqueueSnackbar } from 'notistack';
export default function List() {
const [searchParams, setSearchParams] = useSearchParams();
@@ -76,69 +79,12 @@ export default function List() {
// IMPORT
// Create Button Menu
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const createMenu = Boolean(anchorEl);
const importForm = useRef<HTMLInputElement>(null);
const [currentImportFileName, setCurrentImportFileName] = useState(null);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const handleImportButton = () => {
if (importForm?.current) {
handleClose();
importForm.current ? importForm.current.click() : console.log('No File selected');
} else {
alert('No file selected');
}
};
const handleCancelImportButton = () => {
importForm.current.value = '';
importForm.current.dispatchEvent(new Event('change', { bubbles: true }));
};
const handleImportChange = (event: any) => {
if (event.target.files[0]) {
setCurrentImportFileName(event.target.files[0].name);
} else {
setCurrentImportFileName(null);
}
};
const handleUpload = () => {
if (importForm.current?.files.length) {
const formData = new FormData();
formData.append('file', importForm.current?.files[0]);
axios
.post(`corporates/${corporate_id}/import-plan-benefit`, formData)
.then((response) => {
handleCancelImportButton();
loadDataTableData();
setImportResult(response.data);
// alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
})
.catch((response) => {
enqueueSnackbar(
'Looks like something went wrong. Please check your data and try again. ' +
response.message,
{ variant: 'error' }
);
});
} else {
enqueueSnackbar('No File Selected', { variant: 'warning' });
}
};
return (
<div>
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
<SearchInput onSearch={applyFilter} />
<Button
{/* <Button
variant="outlined"
startIcon={<AddIcon />}
sx={{ p: 1.8 }}
@@ -147,7 +93,7 @@ export default function List() {
}}
>
Create
</Button>
</Button> */}
</Stack>
</div>
);
@@ -213,35 +159,43 @@ export default function List() {
<TableCell align="left">{row.code}</TableCell>
<TableCell align="left">{row.member?.full_name}</TableCell>
<TableCell align="left">{row.plan?.code}</TableCell>
<TableCell align="left">{row.benefit?.code}</TableCell>
<TableCell align="left">{row.claim_request?.service?.name}</TableCell>
<TableCell align="left">
({row.diagnosis?.code}) {row.diagnosis?.name}
({row.diagnoses[0]?.icd?.code}) {row.diagnoses[0]?.icd?.name}
</TableCell>
<TableCell align="left">{fCurrency(row.total_claim)}</TableCell>
{ (row.status == 'approved' && (
<TableCell align="left">Approved</TableCell>
)) }
{ (row.status == 'postpone' && (
<TableCell align="left">Postponed</TableCell>
)) }
<TableCell align="center">
{row.status == 'draft' && (<Chip label='Draft' color="default" variant="outlined" />)}
{row.status == 'requested' && (<Chip label='Requested' color="primary" />)}
{row.status == 'received' && (<Chip label='Received' color="success" variant='outlined' />)}
{row.status == 'approved' && (<Chip label='Approved' color="success" />)}
{row.status == 'postpone' && (<Chip label='Postpone' color="primary" variant="outlined" />)}
{row.status == 'paid' && (<Chip label='Paid' color="warning" />)}
{row.status == 'declined' && (<Chip label='Declined' color="error" />)}
</TableCell>
<TableCell align="right">
<EditRoundedIcon
onClick={(e) => {
{['approved', 'paid'].includes(row.status) && (
<Iconify icon="eva:eye-fill" onClick={(e) => {
navigate('/claims/' + row.id);
}}
/>
}}></Iconify>
)}
{!['approved', 'paid'].includes(row.status) && (
<Iconify icon="eva:edit-outline" onClick={(e) => {
navigate('/claims/' + row.id);
}}></Iconify>
)}
</TableCell>
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={99}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ borderBottom: 1 }}>
{/* <Box sx={{ borderBottom: 1 }}>
<Typography variant="body2" gutterBottom component="div">
Description : {row.description}
</Typography>
</Box>
</Box> */}
</Collapse>
</TableCell>
</TableRow>

View File

@@ -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