ilink-world/webservice/WalletTransferCommission.js

44 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-04-28 09:22:36 +00:00
import { transferCommission } from "./IlinkConstants";
import { store } from "../redux/store";
import axios from "axios";
2020-05-06 13:07:53 +00:00
import I18n from 'react-native-i18n'
2020-04-29 09:45:44 +00:00
import { fetchWalletTransferCommissionPending, fetchWalletTransferCommissionSuccess, fetchWalletTransferCommssionError, walletTransferCommissionReset } from "../redux/actions/WalletActions";
2020-04-28 09:22:36 +00:00
2020-04-29 09:45:44 +00:00
export const transferCommissionAction = (walletID) => {
2020-04-28 09:22:36 +00:00
const auth = store.getState().authKeyReducer;
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
return dispatch => {
dispatch(fetchWalletTransferCommissionPending());
axios({
url: `${transferCommission}/${walletID}`,
method: 'PUT',
headers: {
2020-05-06 13:07:53 +00:00
'Authorization': authKey,
'X-Localization': I18n.currentLocale()
2020-04-28 09:22:36 +00:00
}
})
.then(response => {
console.log(response);
dispatch(fetchWalletTransferCommissionSuccess(response));
})
.catch(error => {
if (error.response)
dispatch(fetchWalletTransferCommssionError(error.response));
else if (error.request)
dispatch(fetchWalletTransferCommssionError(error.request))
else
dispatch(fetchWalletTransferCommssionError(error.message))
});
}
}
2020-04-29 09:45:44 +00:00
export const resetCommissionReducer = () => {
return dispatch => {
dispatch(walletTransferCommissionReset());
}
}