finishing benefit configuration
This commit is contained in:
@@ -1,23 +1,58 @@
|
||||
import axios from "@/utils/axios";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { BenefitConfigurationListType } from "./Types";
|
||||
|
||||
/**
|
||||
* Get Benefit Configuration List
|
||||
*/
|
||||
export const getBenefitConfigurationList = async ( ): Promise<BenefitConfigurationListType[]> => {
|
||||
return [
|
||||
{
|
||||
benefit_name: 'Konsultasi Dokter Umum',
|
||||
amount_incurred: 75000,
|
||||
amount_approved: 75000,
|
||||
amount_not_approved: 0,
|
||||
excess_paid: 0
|
||||
},
|
||||
{
|
||||
benefit_name: 'Biaya Perawatan Setelah Rawat Inap',
|
||||
amount_incurred: 925000,
|
||||
amount_approved: 50000,
|
||||
amount_not_approved: 425000,
|
||||
excess_paid: 0
|
||||
},
|
||||
];
|
||||
export const getBenefitConfigurationList = async ( claim_id: string ): Promise<BenefitConfigurationListType[]> => {
|
||||
const response = await axios.get(`/claims/${claim_id}/benefit-configuration`)
|
||||
.then((res) =>{
|
||||
return res.data.data.benefit_list;
|
||||
})
|
||||
.catch((res) => {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
return [];
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Edit Benefit Configuration
|
||||
*/
|
||||
export const editBenefitConfiguration = async ( data: BenefitConfigurationListType ): Promise<boolean> => {
|
||||
const response = await axios.put(`/claims/benefit-configuration/edit/${data.claim_service_benefits_id}`, {
|
||||
...data
|
||||
})
|
||||
.then((res) =>{
|
||||
enqueueSnackbar(res.data.message, {
|
||||
variant: 'success',
|
||||
});
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch((res) => {
|
||||
if (res.response.status == 400) {
|
||||
let arr_message = res.response.data.message;
|
||||
|
||||
for (const key in arr_message) {
|
||||
enqueueSnackbar(arr_message[key][0], {
|
||||
variant: 'warning',
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Benefit Configuration List Type
|
||||
*/
|
||||
export type BenefitConfigurationListType = {
|
||||
claim_service_benefits_id: number,
|
||||
benefit_name: string,
|
||||
amount_incurred: number,
|
||||
amount_approved: number,
|
||||
|
||||
Reference in New Issue
Block a user