ilink-world/app/webservice/agent/RetraitCarteVersCashAgentAp...

44 lines
1.7 KiB
JavaScript
Executable File

import axios from "axios";
import I18n from 'react-native-i18n';
import { store } from "../../redux/store";
import { idVerificationUrl } from "../IlinkConstants";
import { fetchRetraitCashAgentIdVerificationPending, fetchRetraitCashAgentIdVerificationSuccess, fetchRetraitCashAgentIdVerificationError, fetchRetraitCashAgentIdVerificationReset } from "../../redux/actions/EnvoieAgentAction";
export const checkIdTransactionAction = (data) => {
const auth = store.getState().authKeyReducer;
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
return dispatch => {
dispatch(fetchRetraitCashAgentIdVerificationPending());
axios({
url: `${idVerificationUrl}`,
method: 'POST',
data,
headers: {
'Authorization': authKey,
'X-Localization': I18n.currentLocale()
}
})
.then(response => {
console.log(response);
dispatch(fetchRetraitCashAgentIdVerificationSuccess(response));
})
.catch(error => {
if (error.response)
dispatch(fetchRetraitCashAgentIdVerificationError(error.response));
else if (error.request)
dispatch(fetchRetraitCashAgentIdVerificationError(error.request))
else
dispatch(fetchRetraitCashAgentIdVerificationError(error.message))
});
}
}
export const checkIdTransactionReset = () => {
return dispatch => {
dispatch(fetchRetraitCashAgentIdVerificationReset());
}
}