delete diagnosis exclusion
This commit is contained in:
@@ -29,6 +29,7 @@ class DiagnosisExclusionController extends Controller
|
||||
$exclusions = Exclusion::query()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('type', 'diagnosis')
|
||||
->where('deleted_at', null)
|
||||
->with(['exclusionable', 'rules'])
|
||||
->filter($request->toArray())
|
||||
->paginate();
|
||||
@@ -93,7 +94,13 @@ class DiagnosisExclusionController extends Controller
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
$exclusion = Exclusion::findOrFail($id);
|
||||
|
||||
$exclusion->rules()->delete();
|
||||
$exclusion->delete();
|
||||
return response()->json([
|
||||
'message' => 'Exclusion deleted successfully'
|
||||
]);
|
||||
}
|
||||
|
||||
public function import(Request $request, $corporate_id)
|
||||
|
||||
@@ -82,6 +82,7 @@ Route::prefix('internal')->group(function () {
|
||||
|
||||
Route::get('corporates/{corporate_id}/diagnosis-exclusions', [DiagnosisExclusionController::class, 'index']);
|
||||
Route::post('corporates/{corporate_id}/diagnosis-exclusions/store', [DiagnosisExclusionController::class, 'storeExclusion']);
|
||||
Route::delete('diagnosis-exclusions/{id}', [DiagnosisExclusionController::class, 'destroy']);
|
||||
Route::post('corporates/{corporate_id}/diagnosis-exclusions/import', [DiagnosisExclusionController::class, 'import']);
|
||||
|
||||
Route::get('corporates/{corporate_id}/services', [CorporateServiceController::class, 'index']);
|
||||
|
||||
@@ -28,6 +28,8 @@ import {
|
||||
ButtonGroup,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogActions,
|
||||
DialogTitle,
|
||||
FormControl,
|
||||
FormControlLabel,
|
||||
@@ -49,6 +51,7 @@ import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||
import { Icd } from '../../../@types/diagnosis';
|
||||
import BasePagination from '../../../components/BasePagination';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { Icon } from '@iconify/react';
|
||||
|
||||
export default function List(props: any) {
|
||||
const { themeStretch } = useSettings();
|
||||
@@ -284,6 +287,26 @@ export default function List(props: any) {
|
||||
const { row, index, data } = props;
|
||||
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const [openDelete, setOpenDelete] = React.useState(false);
|
||||
|
||||
const handleDelete = (model: any) => {
|
||||
axios
|
||||
.delete(`/diagnosis-exclusions/${row.id}`)
|
||||
.then((res) => {
|
||||
setDataTableData({
|
||||
...dataTableData,
|
||||
data: dataTableData.data.filter((model) => model.id != row.id),
|
||||
});
|
||||
enqueueSnackbar('Data berhasil dihapus', { variant: 'success' });
|
||||
})
|
||||
.catch((error) => {
|
||||
enqueueSnackbar(
|
||||
error.response.data.message ?? error.message ?? 'Failed Processing Request',
|
||||
{ variant: 'error' }
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const [openEdit, setOpenEdit] = React.useState(false);
|
||||
|
||||
console.log('open', open);
|
||||
@@ -431,11 +454,6 @@ export default function List(props: any) {
|
||||
<TableCell align="left">{row.name}</TableCell>
|
||||
<TableCell align="left">{Object.keys(row.rules).length ? 'With Rules' : 'All'}</TableCell>
|
||||
|
||||
<TableCell align="center">
|
||||
<Button variant="outlined" color="success" size="small">
|
||||
Active
|
||||
</Button>
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
{openEdit ? (
|
||||
<Button
|
||||
@@ -468,23 +486,17 @@ export default function List(props: any) {
|
||||
Edit
|
||||
</Button>
|
||||
)}
|
||||
{/* <Button
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="success"
|
||||
color="error"
|
||||
size="small"
|
||||
sx={{ ml: 2 }}
|
||||
onClick={() => {
|
||||
setOpenEdit(!openEdit);
|
||||
if (open == false) {
|
||||
setOpen(true);
|
||||
}
|
||||
setOpenDelete(true);
|
||||
}}
|
||||
// onClick={() => {
|
||||
// setOpenEdit(true);
|
||||
// setOpen(true);
|
||||
// }}
|
||||
>
|
||||
{openEdit ? 'Save' : 'Edit'}
|
||||
</Button> */}
|
||||
Delete
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/* COLLAPSIBLE ROW */}
|
||||
@@ -716,6 +728,58 @@ export default function List(props: any) {
|
||||
</Collapse>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
<Dialog
|
||||
open={openDelete}
|
||||
onClose={() => {
|
||||
setOpenDelete(false);
|
||||
}}
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
>
|
||||
{/* <DialogTitle id="alert-dialog-title">{'Hapus Dokter'}</DialogTitle> */}
|
||||
<DialogContent sx={{ p: 5 }}>
|
||||
<Icon
|
||||
icon="eva:trash-2-outline"
|
||||
style={{
|
||||
width: '100px',
|
||||
height: '100px',
|
||||
color: '#FF0000',
|
||||
margin: 'auto',
|
||||
display: 'block',
|
||||
marginBottom: '20px',
|
||||
alignContent: 'center',
|
||||
}}
|
||||
/>
|
||||
<DialogContentText sx={{ fontWeight: 'bold', pb: 1 }} id="alert-dialog-title">
|
||||
Apakah anda yakin ingin menghapus
|
||||
</DialogContentText>
|
||||
<Typography sx={{ fontWeight: 'bold' }} id="alert-dialog-title">
|
||||
Exclusion ini?
|
||||
</Typography>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setOpenDelete(false);
|
||||
}}
|
||||
color="primary"
|
||||
variant="outlined"
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
handleDelete(row.id);
|
||||
}}
|
||||
color="primary"
|
||||
variant="contained"
|
||||
autoFocus
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
@@ -797,9 +861,6 @@ export default function List(props: any) {
|
||||
<TableCell style={headStyle} align="left">
|
||||
Rules
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="center">
|
||||
Status
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="center">
|
||||
Action
|
||||
</TableCell>
|
||||
|
||||
Reference in New Issue
Block a user