import {AsyncStorage} from "react-native";
import {persistCombineReducers} from "redux-persist";
import ActiveCountryListReducer from "./ActiveCountryListReducer";
import AskNanoCreditReducer from "./AskNanoCreditReducer";
import authKeyReducer from "./AuthKeyReducer";
import CautionCreditDemandAgentReducer from "./CautionCreditDemandAgentReducer";
import CountryByDialCodeReducer from "./CountryByDialCodeReducer";
import CreateGroupReducer from "./CreateGroupReducer";
import creditCancelDemandReducer from "./CreditCancelDemandReducer";
import creditTreatDemandReducer from "./CreditTreatDemandReducer";
import depositReducer from "./DepositReducer";
import EnvoieUserWalletToCardGetCommissionReducer from "./EnvoieUserWalletToCardGetCommissionReducer";
import EnvoieUserWalletToCardReducer from "./EnvoieUserWalletToCardReducer";
import EnvoieUserWalletToCashGetCommissionReducer from "./EnvoieUserWalletToCashGetCommissionReducer";
import EnvoieUserWalletToCashReducer from "./EnvoieUserWalletToCashReducer";
import EnvoieUserWalletToWalletGetCommissionReducer from "./EnvoieUserWalletToWalletGetCommissionReducer";
import EnvoieUserWalletToWalletReducer from "./EnvoieUserWalletToWalletReducer";
import GetDemandsGroupReducer from "./GetDemandsGroupReducer";
import GetNanoCreditDemandDetailReducer from "./GetNanoCreditDemandDetailReducer";
import GetNanoCreditDemandDurationReducer from "./GetNanoCreditDemandDurationReducer";
import GetNotificationReducer from "./GetNotificationReducer";
import GetNumberInformation from "./GetNumberInformation";
import GetUniqueDemandsGroupReducer from "./GetUniqueDemandsGroupReducer";
import GetUserGroupDetailReducer from "./GetUserGroupDetailReducer";
import GetUserIdentificationReducer from "./GetUserIdentificationReducer";
import CreateIdentificationReducer from "./IdentificationReducer";
import JoinGroupReducer from "./JoinGroupReducer";
import LinkCardReducer from "./LinkCardReducer";
import PayCountryNetworkReducer from "./PayCountryNetworkReducer";
import RefundCreditDemandUserReducer from "./RefundCreditDemandUserReducer";
import RetraitCashAgentIdVerificationReducer from "./RetraitCashAgentIdVerificationReducer";
import SaveOnesignalReducer from "./SaveOnesignalReducer";
import TreatDemandGroupReducer from "./TreatDemandGroupReducer";
import ValidateIdentificationReducer from "./ValidateIdentificationReducer";
import walletDetailReducer from "./WalletDetailReducer.js";
import WalletGetCommissionReducer from "./WalletGetCommissionReducer";
import walletReducer from "./WalletReducer";
import walletHistoryReducer from "./WalletTransactionHistoryReducer";
import walletTransferCommissionReducer from "./WalletTransferCommission";
import EpargnerArgentUserReducer from "./EpargnerArgentUserReducer";
import CasserEpargneUserReducer from "./CasserEpargneUserReducer";
import GetNanoCreditAccountUserReducer from "./GetNanoCreditAccountUserReducer";
import GetNanoCreditHistoryUserReducer from "./GetNanoCreditHistoryUserReducer";
import GetHyperSuperHistoryReducer from "./GetHyperSuperHistoryReducer";
import GetBankListReducer from "./GetBankListReducer";
import EnvoieUserWalletToBank from "./EnvoieUserWalletToBankReducer";
import GetEpargneInProgressReducer from "./GetEpargneInProgressReducer";
import GetNanoCreditUserHistoryInProgressReducer from "./GetNanoCreditUserHistoryInProgressReducer";
import GetListOperatorReducer from "./GetListOperatorReducer";
import PayBillReducer from "./PayBillReducer";
import GetIlinkBankReducer from "./GetIlinkBankReducer";
import ReattachAccountReducer from "./ReattachAccountReducer";
import {
    acceptOrRejectConsultationReducer,
    activatePaySubscriptionReducer,
    addBeneficiaryToSubscriptionReducer,
    addDrugReducer,
    checkInsuranceCoverageAmountReducer,
    createConsultationReducer,
    deleteBeneficiaryeducer,
    demandeAutorisationSoinReducer,
    executionPrescriptionReducer,
    facturerSoinReducer,
    getAmountConsultationReducer,
    getConsultationReducer,
    getDrugAppareilReducer,
    getExclusionReducer,
    getInsurancePrimeAmountReducer,
    getNetworkActReducer,
    getProviderClassReducer,
    getSubscriptionListReducer,
    getUserByIdQRCodeReducer,
    getUserByNameOrNumberReducer,
    insuranceHistoryReducer,
    insuranceListReducer,
    modifyPrescriptionReducer,
    stopSubscriptionReducer,
    subscribeInsuranceReducer,
    uploadInsuranceImagesReducer
} from "../insurance/insurance.reducer";
import SearchUserReducer from "./SearchUserReducer";
import GetQRCodeDetailReducer from "./GetQRCodeDetailReducer";
import PasswordValidationReducer from "./PasswordValidationReducer";

const persistConfig = {
    key: 'root',
    storage: AsyncStorage,
    whitelist: ['authKeyReducer'],
    blacklist: []
};

export const API = 'API';
export const ApiAction = ({
                              url = '',
                              method = 'GET',
                              data = null,
                              accessToken = null,
                              onSuccess = () => {
                              },
                              onLoading = () => {
                              },
                              onError = () => {
                              },
                              ...rest
                          }) => ({
    type: API,
    payload: {
        url,
        method,
        data,
        accessToken,
        onLoading,
        onSuccess,
        onError,
        ...rest,
    },
});

const rootReducer = persistCombineReducers(persistConfig, {
    walletReducer: walletReducer,
    walletDetailReducer: walletDetailReducer,
    authKeyReducer: authKeyReducer,
    depositReducer: depositReducer,
    walletHistoryReducer: walletHistoryReducer,
    walletTransferCommissionReducer: walletTransferCommissionReducer,
    creditTreatDemandReducer: creditTreatDemandReducer,
    creditCancelDemandReducer: creditCancelDemandReducer,
    walletGetCommission: WalletGetCommissionReducer,
    createIdentificationReducer: CreateIdentificationReducer,
    getNumberInformationReducer: GetNumberInformation,
    getUserIdentificationReducer: GetUserIdentificationReducer,
    validateIdentificationReducer: ValidateIdentificationReducer,
    payCountryNetworkReducer: PayCountryNetworkReducer,
    activeCountryListReducer: ActiveCountryListReducer,
    countryByDialCode: CountryByDialCodeReducer,
    envoieUserWalletToWalletReducer: EnvoieUserWalletToWalletReducer,
    envoieUserWalletToWalletGetCommissionReducer: EnvoieUserWalletToWalletGetCommissionReducer,
    envoieUserWalletToCashReducer: EnvoieUserWalletToCashReducer,
    envoieUserWalletToCashGetCommissionReducer: EnvoieUserWalletToCashGetCommissionReducer,
    envoieUserWalletToCardReducer: EnvoieUserWalletToCardReducer,
    envoieUserWalletToCardGetCommissionReducer: EnvoieUserWalletToCardGetCommissionReducer,
    linkCardReduder: LinkCardReducer,
    retraitCashAgentIdVerificationReducer: RetraitCashAgentIdVerificationReducer,
    createGroupReducer: CreateGroupReducer,
    saveOnesignalReducer: SaveOnesignalReducer,
    getDemandsGroupReducer: GetDemandsGroupReducer,
    getUniqueDemandsGroupReducer: GetUniqueDemandsGroupReducer,
    treatDemandGroupReducer: TreatDemandGroupReducer,
    joinGroupReducer: JoinGroupReducer,
    getUserGroupDetailReducer: GetUserGroupDetailReducer,
    getNotificationReducer: GetNotificationReducer,
    askNanoCreditReducer: AskNanoCreditReducer,
    getNanoCreditDemandDurationReducer: GetNanoCreditDemandDurationReducer,
    cautionCreditDemandAgentReducer: CautionCreditDemandAgentReducer,
    refundCreditDemandReducer: RefundCreditDemandUserReducer,
    getNanoCreditDemandDetailReducer: GetNanoCreditDemandDetailReducer,
    epargnerArgentUserReducer: EpargnerArgentUserReducer,
    casserEpargneUserReducer: CasserEpargneUserReducer,
    getNanoCreditAccountUserReducer: GetNanoCreditAccountUserReducer,
    getNanoCreditHistoryUserReducer: GetNanoCreditHistoryUserReducer,
    getHyperSuperHistoryReducer: GetHyperSuperHistoryReducer,
    getBankListReducer: GetBankListReducer,
    envoieUserWalletToBank: EnvoieUserWalletToBank,
    getEpargneInProgressReducer: GetEpargneInProgressReducer,
    getNanoCreditUserHistoryInProgressReducer: GetNanoCreditUserHistoryInProgressReducer,
    getListOperatorReducer: GetListOperatorReducer,
    payBillReducer: PayBillReducer,
    getIlinkBankReducer: GetIlinkBankReducer,
    reattachAccountReducer: ReattachAccountReducer,
    insuranceList: insuranceListReducer,
    subscribeInsurance: subscribeInsuranceReducer,
    insurancePrimeAmount: getInsurancePrimeAmountReducer,
    uploadInsuranceImagesReducer: uploadInsuranceImagesReducer,
    subscriptionList: getSubscriptionListReducer,
    activatePaySubscription: activatePaySubscriptionReducer,
    stopSubscription: stopSubscriptionReducer,
    addBeneficiaryToSubscription: addBeneficiaryToSubscriptionReducer,
    getUserByIdQRCodeReducer: getUserByIdQRCodeReducer,
    getUserByNameOrNumberReducer: getUserByNameOrNumberReducer,
    getDrugAppareilReducer: getDrugAppareilReducer,
    addDrugReducer: addDrugReducer,
    getProviderClassReducer: getProviderClassReducer,
    getNetworkActReducer: getNetworkActReducer,
    createConsultationReducer: createConsultationReducer,
    getAmountConsultationReducer: getAmountConsultationReducer,
    getConsultationReducer: getConsultationReducer,
    acceptOrRejectConsultationReducer: acceptOrRejectConsultationReducer,
    executionPrescriptionReducer: executionPrescriptionReducer,
    modifyPrescriptionReducer: modifyPrescriptionReducer,
    demandeAutorisationSoinReducer: demandeAutorisationSoinReducer,
    deleteBeneficiaryeducer: deleteBeneficiaryeducer,
    facturerSoinReducer: facturerSoinReducer,
    insuranceHistoryReducer: insuranceHistoryReducer,
    checkInsuranceCoverageAmountReducer: checkInsuranceCoverageAmountReducer,
    searchUserReducer: SearchUserReducer,
    getQRCodeDetailReducer: GetQRCodeDetailReducer,
    passwordValidationReducer: PasswordValidationReducer,
    getExclusionReducer: getExclusionReducer
});

export default rootReducer;
