ilink-world/webservice/WalletTransferCommission.js

39 lines
1.5 KiB
JavaScript

import { transferCommission } from "./IlinkConstants";
import { store } from "../redux/store";
import axios from "axios";
import { fetchWalletTransferCommissionPending, fetchWalletTransferCommissionSuccess, fetchWalletTransferCommssionError } from "../redux/actions/WalletActions";
const transferCommissionAction = (walletID) => {
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: {
'Authorization': authKey
}
})
.then(response => {
console.log(response);
dispatch(fetchWalletTransferCommissionSuccess(response));
})
.catch(error => {
console.log(error);
dispatch(fetchWalletTransferCommssionError(error.message));
if (error.response)
dispatch(fetchWalletTransferCommssionError(error.response));
else if (error.request)
dispatch(fetchWalletTransferCommssionError(error.request))
else
dispatch(fetchWalletTransferCommssionError(error.message))
});
}
}
export default transferCommissionAction;