2020-04-28 09:22:36 +00:00
|
|
|
|
|
|
|
import { transactionUrl } 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-05-03 09:16:24 +00:00
|
|
|
import { fetchWalletHistoryPending, fetchWalletHistorySuccess, fetchWalletHistoryError, fetchWalletHistoryReset } from "../redux/actions/WalletActions";
|
2020-04-28 09:22:36 +00:00
|
|
|
|
2020-05-03 09:16:24 +00:00
|
|
|
export const getWalletTransactionHistory = (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(fetchWalletHistoryPending());
|
|
|
|
|
|
|
|
axios({
|
|
|
|
url: `${transactionUrl}/${walletID}`,
|
|
|
|
method: 'GET',
|
|
|
|
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(fetchWalletHistorySuccess(response));
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.log(error);
|
|
|
|
dispatch(fetchWalletHistoryError(error.message));
|
|
|
|
if (error.response)
|
|
|
|
dispatch(fetchWalletHistoryError(error.response));
|
|
|
|
else if (error.request)
|
|
|
|
dispatch(fetchWalletHistoryError(error.request))
|
|
|
|
else
|
|
|
|
dispatch(fetchWalletHistoryError(error.message))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-03 09:16:24 +00:00
|
|
|
export const getWalletTransactionHistoryReset = () => {
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchWalletHistoryReset());
|
|
|
|
}
|
|
|
|
}
|