119 lines
4.5 KiB
JavaScript
119 lines
4.5 KiB
JavaScript
|
|
import axios from "axios";
|
|
import I18n from 'react-native-i18n';
|
|
import { store } from "../../redux/store";
|
|
import { idVerificationUrl, getCreditDemand, groupUrl } from "../IlinkConstants";
|
|
import { fetchRetraitCashAgentIdVerificationPending, fetchRetraitCashAgentIdVerificationSuccess, fetchRetraitCashAgentIdVerificationError, fetchRetraitCashAgentIdVerificationReset } from "../../redux/actions/EnvoieAgentAction";
|
|
import { fetchGetDemandsGroupSuccess, fetchGetDemandsGroupPending, fetchGetDemandsGroupError, fetchGetDemandsGroupReset, fetchGetUniqueDemandsGroupPending, fetchGetUniqueDemandsGroupSuccess, fetchGetUniqueDemandsGroupReset, fetchGetUniqueDemandsGroupError, fetchGetUserGroupDetailPending, fetchGetUserGroupDetailSuccess, fetchGetUserGroupDetailReset } from "../../redux/actions/NanoCreditAction";
|
|
|
|
export const getNanoCreditDemandsAction = (id) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetDemandsGroupPending());
|
|
|
|
axios({
|
|
url: `${getCreditDemand}/all/${id}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetDemandsGroupSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetDemandsGroupError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetDemandsGroupError(error.request))
|
|
else
|
|
dispatch(fetchGetDemandsGroupError(error.message))
|
|
});
|
|
}
|
|
}
|
|
|
|
export const getNanoCreditDemandsReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchGetDemandsGroupReset());
|
|
}
|
|
}
|
|
|
|
export const getNanoCreditUniqueDemandsAction = (id) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetUniqueDemandsGroupPending());
|
|
|
|
axios({
|
|
url: `${getCreditDemand}/${id}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetUniqueDemandsGroupSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetUniqueDemandsGroupError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetUniqueDemandsGroupError(error.request))
|
|
else
|
|
dispatch(fetchGetUniqueDemandsGroupError(error.message))
|
|
});
|
|
}
|
|
}
|
|
|
|
export const getNanoCreditUniqueDemandsReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchGetUniqueDemandsGroupReset());
|
|
}
|
|
}
|
|
|
|
|
|
export const getUserGroupDetailAction = (code_user) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetUserGroupDetailPending());
|
|
|
|
axios({
|
|
url: `${groupUrl}/my/${code_user}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetUserGroupDetailSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetUserGroupDetailError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetUserGroupDetailError(error.request))
|
|
else
|
|
dispatch(fetchGetUserGroupDetailError(error.message))
|
|
});
|
|
}
|
|
}
|
|
|
|
export const getUserGroupDetailReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchGetUserGroupDetailReset());
|
|
}
|
|
} |