update status benefit dan exlusion
This commit is contained in:
@@ -400,7 +400,8 @@ class DiagnosisExclusionController extends Controller
|
||||
}
|
||||
|
||||
Exclusion::where('id', $request->id)->update([
|
||||
'active' => $request->active
|
||||
'active' => $request->active == 1 ? 0 : 1,
|
||||
'reason' => $request->reason
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
|
||||
@@ -326,6 +326,7 @@ class MemberEnrollmentService
|
||||
|
||||
public function __construct(Member $member)
|
||||
{
|
||||
app()->setLocale('en');
|
||||
$this->member = $member;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class Exclusion extends Model
|
||||
'exclusionable_id',
|
||||
'exclusionable_type',
|
||||
'active',
|
||||
'reason'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('exclusions', function (Blueprint $table) {
|
||||
$table->string('reason')->after('active');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('exclusions', function (Blueprint $table) {
|
||||
$table->dropColumn('reason');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -5,9 +5,12 @@ export type Icd = {
|
||||
version?: string;
|
||||
code: string;
|
||||
name: string;
|
||||
service_code: string;
|
||||
active: number;
|
||||
description?: any;
|
||||
childs?: Icd[];
|
||||
status: string;
|
||||
rules:any
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ import TableMoreMenu from '@/components/table/TableMoreMenu';
|
||||
import { Edit } from '@mui/icons-material';
|
||||
import { fData, fNumber } from '@/utils/formatNumber';
|
||||
import DialogUpdateStatus from '@/components/DialogUpdateStatus';
|
||||
|
||||
import { ro } from 'date-fns/locale';
|
||||
|
||||
export default function PlanList() {
|
||||
|
||||
@@ -64,10 +64,10 @@ export default function CorporateTabNavigations({ position }: Props) {
|
||||
path: 'formularium',
|
||||
label: 'Formularium',
|
||||
},
|
||||
{
|
||||
path: 'claim-history',
|
||||
label: 'Claim History',
|
||||
},
|
||||
// {
|
||||
// path: 'claim-history',
|
||||
// label: 'Claim History',
|
||||
// },
|
||||
];
|
||||
useEffect(() => {
|
||||
let currentIndex = mainTabItems.findIndex((item) => item.path === position);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// @mui
|
||||
import * as Yup from 'yup';
|
||||
import {
|
||||
Autocomplete,
|
||||
Box,
|
||||
@@ -46,6 +47,9 @@ import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'reac
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
import { Link, useParams, useSearchParams, useNavigate } from 'react-router-dom';
|
||||
// components
|
||||
import { yupResolver } from '@hookform/resolvers/yup';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import axios from '../../../utils/axios';
|
||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||
import { Icd } from '../../../@types/diagnosis';
|
||||
@@ -59,6 +63,8 @@ import TableMoreMenu from '@/components/table/TableMoreMenu';
|
||||
import { EditOutlined, FindInPageOutlined } from '@mui/icons-material';
|
||||
import Label from '@/components/Label';
|
||||
import { display } from '@mui/system';
|
||||
import DialogUpdateStatus from '@/components/DialogUpdateStatus'
|
||||
import { FormProvider, RHFSelect } from '@/components/hook-form';
|
||||
|
||||
export default function List(props: any) {
|
||||
const { themeStretch } = useSettings();
|
||||
@@ -272,6 +278,14 @@ export default function List(props: any) {
|
||||
...icd,
|
||||
};
|
||||
}
|
||||
type DataContent = {
|
||||
service: string;
|
||||
id: number;
|
||||
status: number;
|
||||
code: string,
|
||||
name: string,
|
||||
rules: string,
|
||||
};
|
||||
const plans = props?.data.map((plan: any) => {
|
||||
return {
|
||||
value: plan.code,
|
||||
@@ -305,6 +319,16 @@ export default function List(props: any) {
|
||||
const { row, index, data } = props;
|
||||
}
|
||||
|
||||
const [isDialogOpen, setDialogOpen] = useState(false)
|
||||
let titles = {
|
||||
name: 'Update Status',
|
||||
icon: '-'
|
||||
}
|
||||
const [dataValue, setDataValue] = useState('');
|
||||
const [dataDescription, setDescriptionValue] = useState('');
|
||||
const [url, setUrl] = useState('');
|
||||
|
||||
|
||||
function Row(props: {
|
||||
row: ReturnType<typeof createData>;
|
||||
data: any;
|
||||
@@ -337,9 +361,6 @@ export default function List(props: any) {
|
||||
|
||||
const [openEdit, setOpenEdit] = React.useState(false);
|
||||
|
||||
console.log('open', open);
|
||||
console.log('openEdit', openEdit);
|
||||
|
||||
// const [plans, setPlans] = useState([]);
|
||||
|
||||
const plans = data;
|
||||
@@ -469,44 +490,53 @@ export default function List(props: any) {
|
||||
|
||||
console.log('exclusions', exclusions);
|
||||
|
||||
const handleActivate = (row: any) => {
|
||||
axios
|
||||
.put(`/corporates/diagnosis-exclusions/update_activation`, {
|
||||
id: row.id,
|
||||
active: row.active == 1 ? 0 : 1,
|
||||
})
|
||||
.then((res) => {
|
||||
setDataTableData({
|
||||
...dataTableData,
|
||||
data: dataTableData.data.map((model) => {
|
||||
let updatedModel = model;
|
||||
// const handleActivate = (row: any) => {
|
||||
|
||||
if (model.id == row.id) {
|
||||
updatedModel.active = row.active == 1 ? 0 : 1;
|
||||
}
|
||||
// axios
|
||||
// .put(`/corporates/diagnosis-exclusions/update_activation`, {
|
||||
// id: row.id,
|
||||
// active: row.active == 1 ? 0 : 1,
|
||||
// })
|
||||
// .then((res) => {
|
||||
// setDataTableData({
|
||||
// ...dataTableData,
|
||||
// data: dataTableData.data.map((model) => {
|
||||
// let updatedModel = model;
|
||||
|
||||
return updatedModel;
|
||||
}),
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.response.status == 400) {
|
||||
let data = error.response.data.messages;
|
||||
// if (model.id == row.id) {
|
||||
// updatedModel.active = row.active == 1 ? 0 : 1;
|
||||
// }
|
||||
|
||||
for (const key in data) {
|
||||
enqueueSnackbar(
|
||||
data[key][0],
|
||||
{ variant: 'error' }
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
enqueueSnackbar(
|
||||
error.response.data.message ?? error.message ?? 'Failed Processing Request',
|
||||
{ variant: 'error' }
|
||||
);
|
||||
}
|
||||
});
|
||||
// return updatedModel;
|
||||
// }),
|
||||
// });
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// if (error.response.status == 400) {
|
||||
// let data = error.response.data.messages;
|
||||
|
||||
// for (const key in data) {
|
||||
// enqueueSnackbar(
|
||||
// data[key][0],
|
||||
// { variant: 'error' }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// enqueueSnackbar(
|
||||
// error.response.data.message ?? error.message ?? 'Failed Processing Request',
|
||||
// { variant: 'error' }
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
|
||||
const handleActivate = (isOpen: boolean, dataValue: DataContent) => {
|
||||
console.log(dataValue)
|
||||
setDialogOpen(isOpen)
|
||||
setDataValue(dataValue)
|
||||
setDescriptionValue('Are you sure to inactive this service ?')
|
||||
setUrl(url)
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -557,7 +587,15 @@ export default function List(props: any) {
|
||||
<EditOutlined />
|
||||
Edit
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => handleActivate(row)}>
|
||||
<MenuItem onClick={() => handleActivate(true, {
|
||||
code: row.code,
|
||||
name: row.name,
|
||||
rules: Object.keys(row.rules).length ? 'With Rules' : 'All',
|
||||
id:row.id,
|
||||
status: row.active,
|
||||
service: row.service_code
|
||||
})
|
||||
} >
|
||||
<CachedIcon />
|
||||
Update Status
|
||||
</MenuItem>
|
||||
@@ -585,16 +623,30 @@ export default function List(props: any) {
|
||||
MSC :
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
|
||||
{row?.rules?.msc && row?.rules?.msc[0] ? (
|
||||
row?.rules?.msc[0].split(',').map((text,i) => {
|
||||
return (
|
||||
<Typography key={i} component="div">
|
||||
<Label>{text}</Label>
|
||||
</Typography>
|
||||
)
|
||||
})
|
||||
) : '-'}
|
||||
<Grid item xs={9} sx={{ display: 'flex', gap: 1 }}>
|
||||
{row?.rules?.msc && row?.rules?.msc[0] ? (
|
||||
row?.rules?.msc[0].split(',').map((text, i) => {
|
||||
let labelMSC: string = text;
|
||||
switch (labelMSC) {
|
||||
case 'm':
|
||||
labelMSC = 'Member';
|
||||
break;
|
||||
case 'c':
|
||||
labelMSC = 'Child';
|
||||
break;
|
||||
case 's':
|
||||
labelMSC = 'Spouse';
|
||||
break;
|
||||
default:
|
||||
labelMSC = 'Member';
|
||||
}
|
||||
return (
|
||||
<Typography key={i} component="div">
|
||||
<Label>{labelMSC}</Label>
|
||||
</Typography>
|
||||
);
|
||||
})
|
||||
) : '-'}
|
||||
</Grid>
|
||||
<Grid item xs={3}>
|
||||
<Typography variant="body1" component="div" color={'GrayText'}>
|
||||
@@ -603,9 +655,14 @@ export default function List(props: any) {
|
||||
</Grid>
|
||||
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
|
||||
{row?.rules?.gender && row?.rules?.gender[0] ? (
|
||||
<Typography component="div">
|
||||
<Label>{row?.rules?.gender[0]}</Label>
|
||||
</Typography>
|
||||
row?.rules?.gender[0].split(',').map((text,i) => {
|
||||
const capitalizedText = text.charAt(0).toUpperCase() + text.slice(1);
|
||||
return (
|
||||
<Typography key={i} component="div">
|
||||
<Label>{capitalizedText}</Label>
|
||||
</Typography>
|
||||
)
|
||||
})
|
||||
) : '-'}
|
||||
</Grid>
|
||||
<Grid item xs={3}>
|
||||
@@ -742,6 +799,18 @@ export default function List(props: any) {
|
||||
fontWeight: 'bold',
|
||||
};
|
||||
|
||||
const onSubmit = async (row : any) => {
|
||||
try {
|
||||
handleUpdate(dataValue.status, dataValue.id, row.reason)
|
||||
} catch (error: any) {
|
||||
console.log('data gagal');
|
||||
}
|
||||
|
||||
const ascent = document?.querySelector('ascent');
|
||||
if (ascent != null) {
|
||||
ascent.innerHTML = '';
|
||||
}
|
||||
};
|
||||
const applyFilter = async (searchFilter: any) => {
|
||||
await loadDataTableData({ search: searchFilter });
|
||||
setSearchParams({ search: searchFilter });
|
||||
@@ -759,6 +828,136 @@ export default function List(props: any) {
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
const NewCorporateSchema = Yup.object().shape({
|
||||
reason: Yup.string().required('Reason Edit is required'),
|
||||
});
|
||||
|
||||
const methods = useForm<FormValuesProps>({
|
||||
resolver: yupResolver(NewCorporateSchema),
|
||||
});
|
||||
|
||||
|
||||
const {
|
||||
reset,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting },
|
||||
} = methods;
|
||||
|
||||
const handleUpdate = (active: number, id: number, reason:string) => {
|
||||
console.log(active)
|
||||
axios
|
||||
.put(`/corporates/diagnosis-exclusions/update_activation`, {
|
||||
id: id,
|
||||
active: active,
|
||||
reason: reason
|
||||
})
|
||||
.then((res) => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
const getContent = () => (
|
||||
<>
|
||||
<Stack paddingX={2} paddingY={2}>
|
||||
<Typography variant='subtitle1'>Are you sure to {dataValue?.status == 1 ? 'inactive' : 'active'} this benefit ?</Typography>
|
||||
</Stack>
|
||||
<Card>
|
||||
<Grid container paddingX={2} paddingY={2}>
|
||||
<Grid item xs={5} md={5}>
|
||||
<Typography variant='inherit'>Service</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={7}>
|
||||
<Typography variant='subtitle1'>{dataValue?.service}</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={5} md={5} marginTop={2}>
|
||||
<Typography variant='inherit'>Code</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={7} marginTop={2}>
|
||||
<Typography variant='subtitle1'>{dataValue?.code}</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={5} md={5} marginTop={2}>
|
||||
<Typography variant='inherit'>Name</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={7} marginTop={2}>
|
||||
<Typography variant='subtitle1'>{dataValue?.name}</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={5} md={5} marginTop={2}>
|
||||
<Typography variant='inherit'>Rules</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={7} marginTop={2}>
|
||||
<Typography variant='subtitle1'>{dataValue?.rules}</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Card>
|
||||
|
||||
<Typography marginTop={5} marginBottom={3} variant='subtitle1'>
|
||||
Reason for update*
|
||||
</Typography>
|
||||
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||
<RHFSelect
|
||||
name="reason"
|
||||
label="Reason for update"
|
||||
>
|
||||
<option value=""></option>
|
||||
<option value="Agreement changed">Agreement changed</option>
|
||||
<option value="Endorsement">Endorsement</option>
|
||||
<option value="Renewal">Renewal</option>
|
||||
<option value="Worng Setting">Worng Setting</option>
|
||||
</RHFSelect>
|
||||
<Stack
|
||||
alignItems="center"
|
||||
justifyContent="flex-end"
|
||||
direction={{ xs: 'column', md: 'row' }}
|
||||
spacing={2}
|
||||
marginTop={5}
|
||||
>
|
||||
<Stack direction="row" spacing={1}>
|
||||
<Button
|
||||
sx={{
|
||||
boxShadow: 'none',
|
||||
}}
|
||||
variant="outlined"
|
||||
size="medium"
|
||||
fullWidth={true}
|
||||
onClick={() => setDialogOpen(false)}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
{dataValue?.status == 1?
|
||||
<LoadingButton
|
||||
sx={{ boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)'}}
|
||||
type="submit"
|
||||
variant="contained"
|
||||
size="medium"
|
||||
fullWidth={true}
|
||||
loading={isSubmitting}
|
||||
color='error'
|
||||
>
|
||||
Inactive
|
||||
</LoadingButton>
|
||||
:
|
||||
<LoadingButton
|
||||
sx={{ boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)'}}
|
||||
type="submit"
|
||||
variant="contained"
|
||||
size="medium"
|
||||
fullWidth={true}
|
||||
loading={isSubmitting}
|
||||
color='success'
|
||||
>
|
||||
Active
|
||||
</LoadingButton>
|
||||
|
||||
|
||||
}
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
</FormProvider>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<ImportForm />
|
||||
@@ -831,6 +1030,16 @@ export default function List(props: any) {
|
||||
|
||||
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange} />
|
||||
</Card>
|
||||
|
||||
<DialogUpdateStatus
|
||||
openDialog={isDialogOpen}
|
||||
setOpenDialog={setDialogOpen}
|
||||
title={titles}
|
||||
data={dataValue}
|
||||
description={dataDescription}
|
||||
content={getContent()}
|
||||
// maxWidth='50px'
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user