2020-04-18 23:19:11 +00:00
|
|
|
|
2020-04-18 19:59:05 +00:00
|
|
|
import { walletActionUrl } from "./IlinkConstants";
|
|
|
|
import { fetchWalletListPending, fetchWalletListSuccess, fetchWalletListError } from "../redux/actions/WalletActions";
|
2020-04-18 23:19:11 +00:00
|
|
|
import { store } from "../redux/store";
|
|
|
|
import axios from "axios";
|
2020-04-18 19:59:05 +00:00
|
|
|
|
|
|
|
const getWalletActivated = (userID) => {
|
|
|
|
|
2020-04-18 23:19:11 +00:00
|
|
|
const auth = store.getState().authKeyReducer;
|
|
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
|
2020-04-18 19:59:05 +00:00
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchWalletListPending());
|
|
|
|
|
2020-04-18 23:19:11 +00:00
|
|
|
axios({
|
|
|
|
url: `${walletActionUrl}/${userID}/activated`,
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'Authorization': authKey
|
|
|
|
}
|
|
|
|
})
|
2020-04-18 19:59:05 +00:00
|
|
|
.then(response => {
|
2020-04-24 15:11:08 +00:00
|
|
|
console.log(response);
|
2020-04-18 19:59:05 +00:00
|
|
|
dispatch(fetchWalletListSuccess(response));
|
|
|
|
})
|
|
|
|
.catch(error => {
|
2020-04-24 15:11:08 +00:00
|
|
|
console.log(error);
|
2020-04-18 19:59:05 +00:00
|
|
|
dispatch(fetchWalletListError(error.message));
|
2020-04-20 10:43:01 +00:00
|
|
|
if (error.response)
|
|
|
|
dispatch(fetchWalletListError(error.response));
|
|
|
|
else if (error.request)
|
|
|
|
dispatch(fetchWalletListError(error.request))
|
|
|
|
else
|
|
|
|
dispatch(fetchWalletListError(error.message))
|
2020-04-18 19:59:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default getWalletActivated;
|