ilink-world/webservice/EnvoieUserApi.js

44 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-06-23 10:28:52 +00:00
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());
}
}