|
|
|
|
@@ -1,4 +1,5 @@
|
|
|
|
|
// @mui
|
|
|
|
|
import * as Yup from 'yup';
|
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
@@ -38,6 +39,8 @@ import HistoryIcon from '@mui/icons-material/History';
|
|
|
|
|
import CachedOutlinedIcon from '@mui/icons-material/CachedOutlined';
|
|
|
|
|
import FindInPageOutlinedIcon from '@mui/icons-material/FindInPageOutlined';
|
|
|
|
|
|
|
|
|
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
|
|
|
import { useForm } from 'react-hook-form';
|
|
|
|
|
|
|
|
|
|
// hooks
|
|
|
|
|
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
|
|
|
|
@@ -72,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() {
|
|
|
|
|
const { themeStretch } = useSettings();
|
|
|
|
|
@@ -313,12 +317,18 @@ export default function PlanList() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type DataContent = {
|
|
|
|
|
code: string;
|
|
|
|
|
name: string;
|
|
|
|
|
service: string;
|
|
|
|
|
id: number;
|
|
|
|
|
status: string|number;
|
|
|
|
|
status: number;
|
|
|
|
|
plan: string,
|
|
|
|
|
benefit_code: string,
|
|
|
|
|
customer_benefit_code: string,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type FormValuesProps = {
|
|
|
|
|
value: string;
|
|
|
|
|
active: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Generate the every row of the table
|
|
|
|
|
const [isDialogOpen, setDialogOpen] = useState(false)
|
|
|
|
|
@@ -335,6 +345,14 @@ export default function PlanList() {
|
|
|
|
|
const [open, setOpen] = React.useState(false);
|
|
|
|
|
const [openEdit, setOpenEdit] = React.useState(false);
|
|
|
|
|
|
|
|
|
|
const handleActivate = (isOpen: boolean, dataValue: DataContent) => {
|
|
|
|
|
console.log(dataValue)
|
|
|
|
|
setDialogOpen(isOpen)
|
|
|
|
|
setDataValue(dataValue)
|
|
|
|
|
setDescriptionValue('Are you sure to inactive this service ?')
|
|
|
|
|
setUrl(url)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// const handleActivate = (model: any, status: string) => {
|
|
|
|
|
// axios
|
|
|
|
|
// .put(`/benefits/${row.id}/activation`, {
|
|
|
|
|
@@ -362,14 +380,6 @@ export default function PlanList() {
|
|
|
|
|
// });
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleActivate = (isOpen: boolean, dataValue: DataContent) => {
|
|
|
|
|
setDialogOpen(isOpen)
|
|
|
|
|
setDataValue(dataValue)
|
|
|
|
|
setDescriptionValue('Are you sure to inactive this service ?')
|
|
|
|
|
setUrl(url)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let frequency_period_name: string
|
|
|
|
|
switch (row.max_frequency_period) {
|
|
|
|
|
case '1' :
|
|
|
|
|
@@ -476,7 +486,18 @@ export default function PlanList() {
|
|
|
|
|
<HistoryIcon />
|
|
|
|
|
History
|
|
|
|
|
</MenuItem>
|
|
|
|
|
<MenuItem onClick={() => handleActivate(true, {code: row.code, name: row.service_code, id:row.id, status: row.active}) }>
|
|
|
|
|
<MenuItem
|
|
|
|
|
onClick={() =>
|
|
|
|
|
handleActivate(true, {
|
|
|
|
|
service: row.benefit?.service_code,
|
|
|
|
|
plan: row.plan?.code,
|
|
|
|
|
benefit_code: row.benefit?.code,
|
|
|
|
|
customer_benefit_code: row.corporate_benefit_code,
|
|
|
|
|
id:row.id,
|
|
|
|
|
status: row.active
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<CachedOutlinedIcon />
|
|
|
|
|
Update Status
|
|
|
|
|
</MenuItem>
|
|
|
|
|
@@ -866,7 +887,7 @@ export default function PlanList() {
|
|
|
|
|
const loadDataTableData = async (appliedFilter = null) => {
|
|
|
|
|
setDataTableLoading(true);
|
|
|
|
|
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
|
|
|
|
const response = await axios.get('/corporates/' + corporate_id + '/benefits', {
|
|
|
|
|
const response = await axios.get('/corporates/' + corporate_id + '/corporate-benefits', {
|
|
|
|
|
params: filter,
|
|
|
|
|
});
|
|
|
|
|
// console.log(response.data);
|
|
|
|
|
@@ -879,6 +900,19 @@ export default function PlanList() {
|
|
|
|
|
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: string) => {
|
|
|
|
|
await loadDataTableData({ search: searchFilter });
|
|
|
|
|
setSearchParams({ search: searchFilter });
|
|
|
|
|
@@ -894,25 +928,64 @@ export default function PlanList() {
|
|
|
|
|
loadDataTableData();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
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(`/benefits/${id}/activation`, {
|
|
|
|
|
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 service ?</Typography>
|
|
|
|
|
<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={4} md={4}>
|
|
|
|
|
<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'>Plan</Typography>
|
|
|
|
|
</Grid>
|
|
|
|
|
<Grid item xs={7} marginTop={2}>
|
|
|
|
|
<Typography variant='subtitle1'>{dataValue?.plan}</Typography>
|
|
|
|
|
</Grid>
|
|
|
|
|
<Grid item xs={5} md={5} marginTop={2}>
|
|
|
|
|
<Typography variant='inherit'>Code</Typography>
|
|
|
|
|
</Grid>
|
|
|
|
|
<Grid item xs={8}>
|
|
|
|
|
<Typography variant='subtitle1'>{dataValue?.code}</Typography>
|
|
|
|
|
<Grid item xs={7} marginTop={2}>
|
|
|
|
|
<Typography variant='subtitle1'>{dataValue?.benefit_code}</Typography>
|
|
|
|
|
</Grid>
|
|
|
|
|
<Grid item xs={4} md={4} marginTop={2}>
|
|
|
|
|
<Typography variant='inherit'>Service Name</Typography>
|
|
|
|
|
<Grid item xs={5} md={5} marginTop={2}>
|
|
|
|
|
<Typography variant='inherit'>Customer Benefit Code</Typography>
|
|
|
|
|
</Grid>
|
|
|
|
|
<Grid item xs={8} marginTop={2}>
|
|
|
|
|
<Typography variant='subtitle1'>{dataValue?.name}</Typography>
|
|
|
|
|
<Grid item xs={7} marginTop={2}>
|
|
|
|
|
<Typography variant='subtitle1'>{dataValue?.customer_benefit_code}</Typography>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Card>
|
|
|
|
|
@@ -1058,7 +1131,7 @@ export default function PlanList() {
|
|
|
|
|
title={{ name: 'Reason For Update' }}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{/* <DialogUpdateStatus
|
|
|
|
|
<DialogUpdateStatus
|
|
|
|
|
openDialog={isDialogOpen}
|
|
|
|
|
setOpenDialog={setDialogOpen}
|
|
|
|
|
title={titles}
|
|
|
|
|
@@ -1066,7 +1139,7 @@ export default function PlanList() {
|
|
|
|
|
description={dataDescription}
|
|
|
|
|
content={getContent()}
|
|
|
|
|
// maxWidth='50px'
|
|
|
|
|
/> */}
|
|
|
|
|
/>
|
|
|
|
|
</Stack>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|