progress 2 feature/dashboard-create-claim-request
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import axios from '@/utils/axios';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { MemberListType } from './Types';
|
||||
import { makeFormData } from '@/utils/jsonToFormData';
|
||||
|
||||
/**
|
||||
* Listing Member
|
||||
@@ -20,3 +21,53 @@ export const getMemberList = async ( page: number, keyword: string ): Promise<Me
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add Claim Request
|
||||
*/
|
||||
export const addClaimRequest = async ( data: MemberListType[] ): Promise<boolean> => {
|
||||
// Mapping
|
||||
const formData = new FormData();
|
||||
|
||||
data.map((row, index) => {
|
||||
formData.append(`member_id[${index}]`, row.id.toString());
|
||||
formData.append(`service_code[${index}]`, row.patien_type??'');
|
||||
|
||||
if (row.invoice_files != undefined) {
|
||||
row.invoice_files.forEach((file, file_index) => {
|
||||
formData.append(`invoice[${index}][${file_index}]`, file);
|
||||
});
|
||||
}
|
||||
|
||||
if (row.prescription_files != undefined) {
|
||||
row.prescription_files.forEach((file, file_index) => {
|
||||
formData.append(`prescription[${index}][${file_index}]`, file);
|
||||
});
|
||||
}
|
||||
|
||||
if (row.laboratorium_files != undefined) {
|
||||
row.laboratorium_files.forEach((file, file_index) => {
|
||||
formData.append(`laboratorium[${index}][${file_index}]`, file);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
// Axios
|
||||
const response = await axios.post(`/claim-requests`, formData)
|
||||
.then((res) =>{
|
||||
enqueueSnackbar("Berhasil membuat data !", {
|
||||
variant: 'success',
|
||||
});
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch((res) => {
|
||||
enqueueSnackbar("server error !", {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
@@ -9,7 +9,11 @@ export type SearchType = {
|
||||
* Member List
|
||||
*/
|
||||
export type MemberListType = {
|
||||
id : string,
|
||||
member_id : string,
|
||||
name : string,
|
||||
id : string,
|
||||
member_id : string,
|
||||
name : string,
|
||||
patien_type? : string,
|
||||
invoice_files? : any[],
|
||||
laboratorium_files? : any[],
|
||||
prescription_files? : any[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user