ilink-world/redux/insurance/insurance.actions.js

466 lines
14 KiB
JavaScript
Raw Normal View History

2021-10-26 18:19:13 +00:00
/**
* Project YooLearn
* File skills.actions
* Path app/redux/skills
* Created by BRICE ZELE
* Date: 13/09/2021
*/
import InsuranceActions from './insurance.type';
import {
2021-11-29 11:30:04 +00:00
createConsultationUrl,
2021-11-30 15:33:51 +00:00
getAmountConsultationUrl,
2021-11-29 11:30:04 +00:00
getDrugAndDevicesUrl,
2021-10-26 18:19:13 +00:00
getInsuranceListUrl,
getInsurancePrimeAmountUrl,
2021-11-29 11:30:04 +00:00
getNetworkActsUrl,
getProviderClassUrl,
2021-11-22 18:20:54 +00:00
getUserByIdQRCodeUrl,
getUserByNameOrNumberUrl,
2021-10-26 18:19:13 +00:00
subscribeInsuranceUrl,
uploadInsuranceImagetUrl
} from "../../webservice/IlinkConstants";
import {ApiAction} from "../reducers";
export const fetchGetListInsurancePending = () => ({
type: InsuranceActions.GET_INSURANCE_LIST_PENDING,
});
export const fetchGetListInsuranceReset = () => ({
type: InsuranceActions.GET_INSURANCE_LIST_RESET,
});
export const fetchGetListInsuranceSuccess = (authkey: any) => ({
type: InsuranceActions.GET_INSURANCE_LIST_SUCCESS,
payload: authkey,
});
export const fetchGetListInsuranceError = (error: any) => ({
type: InsuranceActions.GET_INSURANCE_LIST_ERROR,
payload: error,
});
export const fetchGetListInsurance = (idCountry) => {
return ApiAction({
2021-11-11 11:43:33 +00:00
url: `${getInsuranceListUrl}/networks?country_id=${idCountry}`,
2021-10-26 18:19:13 +00:00
method: 'GET',
onLoading: fetchGetListInsurancePending,
onSuccess: fetchGetListInsuranceSuccess,
onError: fetchGetListInsuranceError,
});
};
/************************************************************/
export const fetchSubscribeInsurancePending = () => ({
type: InsuranceActions.SUBSCRIBE_INSURANCE_PENDING,
});
export const fetchSubscribeInsuranceReset = () => ({
type: InsuranceActions.SUBSCRIBE_INSURANCE_RESET,
});
export const fetchSubscribeInsuranceSuccess = (authkey: any) => ({
type: InsuranceActions.SUBSCRIBE_INSURANCE_SUCCESS,
payload: authkey,
});
export const fetchSubscribeInsuranceError = (error: any) => ({
type: InsuranceActions.SUBSCRIBE_INSURANCE_ERROR,
payload: error,
});
export const fetchSubscribeInsurance = (data) => {
return ApiAction({
url: subscribeInsuranceUrl,
data,
method: 'POST',
onLoading: fetchSubscribeInsurancePending,
onSuccess: fetchSubscribeInsuranceSuccess,
onError: fetchSubscribeInsuranceError,
});
};
/************************************************************/
export const fetchGetInsurancePrimeAmountPending = () => ({
type: InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_PENDING,
});
export const fetchGetInsurancePrimeAmountReset = () => ({
type: InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_RESET,
});
export const fetchGetInsurancePrimeAmountSuccess = (authkey: any) => ({
type: InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_SUCCESS,
payload: authkey,
});
export const fetchGetInsurancePrimeAmountError = (error: any) => ({
type: InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_ERROR,
payload: error,
});
export const fetchGetInsurancePrimeAmount = (data) => {
return ApiAction({
url: getInsurancePrimeAmountUrl,
data,
method: 'POST',
onLoading: fetchGetInsurancePrimeAmountPending,
onSuccess: fetchGetInsurancePrimeAmountSuccess,
onError: fetchGetInsurancePrimeAmountError,
});
};
/************************************************************/
export const fetchUploadInsurancePending = () => ({
type: InsuranceActions.UPLOAD_INSURANCE_IMAGES_PENDING,
});
export const fetchUploadInsuranceReset = () => ({
type: InsuranceActions.UPLOAD_INSURANCE_IMAGES_RESET,
});
export const fetchUploadInsuranceSuccess = (authkey: any) => ({
type: InsuranceActions.UPLOAD_INSURANCE_IMAGES_SUCCESS,
payload: authkey,
});
export const fetchUploadInsuranceError = (error: any) => ({
type: InsuranceActions.UPLOAD_INSURANCE_IMAGES_ERROR,
payload: error,
});
export const fetchUploadInsurance = (data) => {
return ApiAction({
url: uploadInsuranceImagetUrl,
data,
accessToken: 'gZ7KibrSvFNLxrGz49usnRiKBZ4OlX99',
method: 'POST',
onLoading: fetchUploadInsurancePending,
onSuccess: fetchUploadInsuranceSuccess,
onError: fetchUploadInsuranceError,
});
};
2021-11-11 11:43:33 +00:00
/************************************************************/
export const fetchGetSubscriptionListPending = () => ({
type: InsuranceActions.GET_SUBSCRIPTION_LIST_PENDING,
});
export const fetchGetSubscriptionListReset = () => ({
type: InsuranceActions.GET_SUBSCRIPTION_LIST_RESET,
});
export const fetchGetSubscriptionListSuccess = (authkey: any) => ({
type: InsuranceActions.GET_SUBSCRIPTION_LIST_SUCCESS,
payload: authkey,
});
export const fetchGetSubscriptionListError = (error: any) => ({
type: InsuranceActions.GET_SUBSCRIPTION_LIST_ERROR,
payload: error,
});
export const fetchGetSubscriptionList = (idUser, type, includeSubscription = true) => {
return ApiAction({
url: includeSubscription ? `${getInsuranceListUrl}/subscriptions?user_id=${idUser}&type=${type}` : `${getInsuranceListUrl}?user_id=${idUser}&type=${type}`,
method: 'GET',
onLoading: fetchGetSubscriptionListPending,
onSuccess: fetchGetSubscriptionListSuccess,
onError: fetchGetSubscriptionListError,
});
};
/************************************************************/
export const fetchActivePaySubscriptionPending = () => ({
type: InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_PENDING,
});
export const fetchActivePaySubscriptionReset = () => ({
type: InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_RESET,
});
export const fetchActivePaySubscriptionSuccess = (authkey: any) => ({
type: InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_SUCCESS,
payload: authkey,
});
export const fetchActivePaySubscriptionError = (error: any) => ({
type: InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_ERROR,
payload: error,
});
export const fetchActivePaySubscription = (id, data) => {
return ApiAction({
url: `${subscribeInsuranceUrl}/${id}/pay`,
data,
method: 'PUT',
onLoading: fetchActivePaySubscriptionPending,
onSuccess: fetchActivePaySubscriptionSuccess,
onError: fetchActivePaySubscriptionError,
});
};
/************************************************************/
export const fetchAddBeneficiaryToSubscriptionPending = () => ({
type: InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_PENDING,
});
export const fetchAddBeneficiaryToSubscriptionReset = () => ({
type: InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_RESET,
});
export const fetchAddBeneficiaryToSubscriptionSuccess = (authkey: any) => ({
type: InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_SUCCESS,
payload: authkey,
});
export const fetchAddBeneficiaryToSubscriptionError = (error: any) => ({
type: InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_ERROR,
payload: error,
});
export const fetchAddBeneficiaryToSubscription = (id, data) => {
return ApiAction({
url: `${getInsuranceListUrl}/${id}/add-beneficiaries`,
data,
method: 'PUT',
onLoading: fetchAddBeneficiaryToSubscriptionPending,
onSuccess: fetchAddBeneficiaryToSubscriptionSuccess,
onError: fetchAddBeneficiaryToSubscriptionError,
});
};
2021-11-22 18:20:54 +00:00
/************************************************************/
export const fetchGetUserByIdQRCodePending = () => ({
type: InsuranceActions.GET_USER_BY_ID_QR_CODE_PENDING,
});
export const fetchGetUserByIdQRCodeReset = () => ({
type: InsuranceActions.GET_USER_BY_ID_QR_CODE_RESET,
});
export const fetchGetUserByIdQRCodeSuccess = (authkey: any) => ({
type: InsuranceActions.GET_USER_BY_ID_QR_CODE_SUCCESS,
payload: authkey,
});
export const fetchGetUserByIdQRCodeError = (error: any) => ({
type: InsuranceActions.GET_USER_BY_ID_QR_CODE_ERROR,
payload: error,
});
export const fetchGetUserByIdQRCode = (network_id, id) => {
return ApiAction({
url: `${getUserByIdQRCodeUrl}?network_id=${network_id}&${id}`,
method: 'GET',
onLoading: fetchGetUserByIdQRCodePending,
onSuccess: fetchGetUserByIdQRCodeSuccess,
onError: fetchGetUserByIdQRCodeError,
});
};
/************************************************************/
export const fetchGetUserByNameOrNumberPending = () => ({
type: InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_PENDING,
});
export const fetchGetUserByNameOrNumberReset = () => ({
type: InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_RESET,
});
export const fetchGetUserByNameOrNumberSuccess = (authkey: any) => ({
type: InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_SUCCESS,
payload: authkey,
});
export const fetchGetUserByNameOrNumberError = (error: any) => ({
type: InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_ERROR,
payload: error,
});
export const fetchGetUserByNameOrNumber = (network_id, id) => {
return ApiAction({
url: `${getUserByNameOrNumberUrl}?network_id=${network_id}&${id}`,
method: 'GET',
onLoading: fetchGetUserByNameOrNumberPending,
onSuccess: fetchGetUserByNameOrNumberSuccess,
onError: fetchGetUserByNameOrNumberError,
});
};
2021-11-29 11:30:04 +00:00
/************************************************************/
export const fetchGetDrugAppareilPending = () => ({
type: InsuranceActions.GET_DRUG_APPAREIL_PENDING,
});
export const fetchGetDrugAppareilReset = () => ({
type: InsuranceActions.GET_DRUG_APPAREIL_RESET,
});
export const fetchGetDrugAppareilSuccess = (authkey: any) => ({
type: InsuranceActions.GET_DRUG_APPAREIL_SUCCESS,
payload: authkey,
});
export const fetchGetDrugAppareilError = (error: any) => ({
type: InsuranceActions.GET_DRUG_APPAREIL_ERROR,
payload: error,
});
export const fetchGetDrugAppareil = (network_id, name) => {
return ApiAction({
url: `${getDrugAndDevicesUrl}?network_id=${network_id}&name=${name}`,
method: 'GET',
onLoading: fetchGetDrugAppareilPending,
onSuccess: fetchGetDrugAppareilSuccess,
onError: fetchGetDrugAppareilError,
});
};
/************************************************************/
export const fetchAddDrugPending = () => ({
type: InsuranceActions.ADD_DRUG_PENDING,
});
export const fetchAddDrugReset = () => ({
type: InsuranceActions.ADD_DRUG_RESET,
});
export const fetchAddDrugSuccess = (authkey: any) => ({
type: InsuranceActions.ADD_DRUG_SUCCESS,
payload: authkey,
});
export const fetchAddDrugError = (error: any) => ({
type: InsuranceActions.ADD_DRUG_ERROR,
payload: error,
});
export const fetchAddDrug = (data) => {
return ApiAction({
url: `${getDrugAndDevicesUrl}`,
method: 'POST',
data,
onLoading: fetchAddDrugPending,
onSuccess: fetchAddDrugSuccess,
onError: fetchAddDrugError,
});
};
/************************************************************/
export const fetchGetProviderClassPending = () => ({
type: InsuranceActions.GET_PROVIDER_CLASS_PENDING,
});
export const fetchGetProviderClassReset = () => ({
type: InsuranceActions.GET_PROVIDER_CLASS_RESET,
});
export const fetchGetProviderClassSuccess = (authkey: any) => ({
type: InsuranceActions.GET_PROVIDER_CLASS_SUCCESS,
payload: authkey,
});
export const fetchGetProviderClassError = (error: any) => ({
type: InsuranceActions.GET_PROVIDER_CLASS_ERROR,
payload: error,
});
export const fetchGetProviderClass = (network_id) => {
return ApiAction({
url: `${getProviderClassUrl}?network_id=${network_id}`,
method: 'GET',
onLoading: fetchGetProviderClassPending,
onSuccess: fetchGetProviderClassSuccess,
onError: fetchGetProviderClassError,
});
};
/************************************************************/
export const fetchGetNetworkActsPending = () => ({
type: InsuranceActions.GET_NETWORK_ACT_PENDING,
});
export const fetchGetNetworkActsReset = () => ({
type: InsuranceActions.GET_NETWORK_ACT_RESET,
});
export const fetchGetNetworkActsSuccess = (authkey: any) => ({
type: InsuranceActions.GET_NETWORK_ACT_SUCCESS,
payload: authkey,
});
export const fetchGetNetworkActsError = (error: any) => ({
type: InsuranceActions.GET_NETWORK_ACT_ERROR,
payload: error,
});
export const fetchGetNetworkActs = (network_id, code = '') => {
return ApiAction({
url: `${getNetworkActsUrl}?network_id=${network_id}&code=${code}`,
method: 'GET',
onLoading: fetchGetNetworkActsPending,
onSuccess: fetchGetNetworkActsSuccess,
onError: fetchGetNetworkActsError,
});
};
/************************************************************/
export const fetchCreateConsultationPending = () => ({
type: InsuranceActions.CREATE_CONSULTATION_PENDING,
});
export const fetchCreateConsultationReset = () => ({
type: InsuranceActions.CREATE_CONSULTATION_RESET,
});
export const fetchCreateConsultationSuccess = (authkey: any) => ({
type: InsuranceActions.CREATE_CONSULTATION_SUCCESS,
payload: authkey,
});
export const fetchCreateConsultationError = (error: any) => ({
type: InsuranceActions.CREATE_CONSULTATION_ERROR,
payload: error,
});
export const fetchCreateConsultation = (data) => {
return ApiAction({
url: `${createConsultationUrl}`,
method: 'POST',
data,
onLoading: fetchCreateConsultationPending,
onSuccess: fetchCreateConsultationSuccess,
onError: fetchCreateConsultationError,
});
};
2021-11-30 15:33:51 +00:00
/************************************************************/
export const fetchGetAmountConsultationPending = () => ({
type: InsuranceActions.GET_AMOUNT_CONSULTATION_PENDING,
});
export const fetchGetAmountConsultationReset = () => ({
type: InsuranceActions.GET_AMOUNT_CONSULTATION_RESET,
});
export const fetchGetAmountConsultationSuccess = (authkey: any) => ({
type: InsuranceActions.GET_AMOUNT_CONSULTATION_SUCCESS,
payload: authkey,
});
export const fetchGetAmountConsultationError = (error: any) => ({
type: InsuranceActions.GET_AMOUNT_CONSULTATION_ERROR,
payload: error,
});
export const fetchGetAmountConsultation = (data) => {
return ApiAction({
url: `${getAmountConsultationUrl}`,
method: 'POST',
data,
onLoading: fetchGetAmountConsultationPending,
onSuccess: fetchGetAmountConsultationSuccess,
onError: fetchGetAmountConsultationError,
});
};