import axios from "axios"; import I18n from 'react-native-i18n'; import { store } from "../redux/store"; import { envoieUserWalletToWallet } from "./IlinkConstants"; import { fetchEnvoieUserWalletToWalletPending, fetchEnvoieUserWalletToWalletSuccess, fetchEnvoieUserWalletToWalletError, fetchEnvoieUserWalletToWalletReset } from "../redux/actions/EnvoieUserType"; export const envoieUserWalletToWalletAction = (data) => { const auth = store.getState().authKeyReducer; const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : ''; return dispatch => { dispatch(fetchEnvoieUserWalletToWalletPending()); axios({ url: `${envoieUserWalletToWallet}`, method: 'GET', data, headers: { 'Authorization': authKey, 'X-Localization': I18n.currentLocale() } }) .then(response => { console.log(response); dispatch(fetchEnvoieUserWalletToWalletSuccess(response)); }) .catch(error => { if (error.response) dispatch(fetchEnvoieUserWalletToWalletError(error.response)); else if (error.request) dispatch(fetchEnvoieUserWalletToWalletError(error.request)) else dispatch(fetchEnvoieUserWalletToWalletError(error.message)) }); } } export const envoieUserWalletToWalletReset = () => { return dispatch => { dispatch(fetchEnvoieUserWalletToWalletReset()); } }