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

135 lines
3.9 KiB
JavaScript

/**
* 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}/${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,
});
};