/** * Project YooLearn * File skills.actions * Path app/redux/skills * Created by BRICE ZELE * Date: 13/09/2021 */ import InsuranceActions from './insurance.type'; import { getInsuranceListUrl, getInsurancePrimeAmountUrl, 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({ url: `${getInsuranceListUrl}/networks?country_id=${idCountry}`, 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, }); }; /************************************************************/ 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, }); };