2020-08-12 18:24:56 +00:00
|
|
|
|
|
|
|
import axios from "axios";
|
|
|
|
import I18n from 'react-native-i18n';
|
|
|
|
import { store } from "../../redux/store";
|
2020-09-30 05:46:30 +00:00
|
|
|
import { fetchCautionCreditDemandUserError, fetchCautionCreditDemandUserPending, fetchCautionCreditDemandUserReset, fetchCautionCreditDemandUserSuccess, fetchGetDemandsGroupError, fetchGetDemandsGroupPending, fetchGetDemandsGroupReset, fetchGetDemandsGroupSuccess, fetchGetUniqueDemandsGroupError, fetchGetUniqueDemandsGroupPending, fetchGetUniqueDemandsGroupReset, fetchGetUniqueDemandsGroupSuccess, fetchGetUserGroupDetailError, fetchGetUserGroupDetailPending, fetchGetUserGroupDetailReset, fetchGetUserGroupDetailSuccess, fetchEpargnerArgentUserPending, fetchEpargnerArgentUserSuccess, fetchEpargnerArgentUserError, fetchEpargnerArgentUserReset, fetchCasserEpargneUserPending, fetchCasserEpargneUserSuccess, fetchCasserEpargneUserError, fetchCasserEpargneUserReset, fetchGetNanoCreditUserAccountPending, fetchGetNanoCreditUserAccountSuccess, fetchGetNanoCreditUserAccountError, fetchGetNanoCreditUserAccountReset } from "../../redux/actions/NanoCreditAction";
|
|
|
|
import { cautionCreditDemandtUrl, getCreditDemand, groupUrl, refundCreditDemandUrl, epargnerArgentUrl, casserEpargneUrl, getNanoCreditAccount } from "../IlinkConstants";
|
2020-08-12 18:24:56 +00:00
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
2020-08-13 05:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
2020-08-23 21:41:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
2020-09-07 16:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const refundCreditDemandUserAction = (data) => {
|
|
|
|
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchCautionCreditDemandUserPending());
|
|
|
|
|
|
|
|
axios({
|
|
|
|
url: refundCreditDemandUrl,
|
|
|
|
method: 'POST',
|
|
|
|
data,
|
|
|
|
headers: {
|
|
|
|
'Authorization': authKey,
|
|
|
|
'X-Localization': I18n.currentLocale()
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
console.log(response);
|
|
|
|
dispatch(fetchCautionCreditDemandUserSuccess(response));
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
if (error.response)
|
|
|
|
dispatch(fetchCautionCreditDemandUserError(error.response));
|
|
|
|
else if (error.request)
|
|
|
|
dispatch(fetchCautionCreditDemandUserError(error.request))
|
|
|
|
else
|
|
|
|
dispatch(fetchCautionCreditDemandUserError(error.message))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const refundCreditDemandUserReset = () => {
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchCautionCreditDemandUserReset());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const epargnerArgentUserAction = (data) => {
|
|
|
|
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchEpargnerArgentUserPending());
|
|
|
|
|
|
|
|
axios({
|
|
|
|
url: epargnerArgentUrl,
|
|
|
|
method: 'POST',
|
|
|
|
data,
|
|
|
|
headers: {
|
|
|
|
'Authorization': authKey,
|
|
|
|
'X-Localization': I18n.currentLocale()
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
console.log(response);
|
|
|
|
dispatch(fetchEpargnerArgentUserSuccess(response));
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
if (error.response)
|
|
|
|
dispatch(fetchEpargnerArgentUserError(error.response));
|
|
|
|
else if (error.request)
|
|
|
|
dispatch(fetchEpargnerArgentUserError(error.request))
|
|
|
|
else
|
|
|
|
dispatch(fetchEpargnerArgentUserError(error.message))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const epargnerArgentUserReset = () => {
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchEpargnerArgentUserReset());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const casserEpargneUserAction = (data) => {
|
|
|
|
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchCasserEpargneUserPending());
|
|
|
|
|
|
|
|
axios({
|
|
|
|
url: casserEpargneUrl,
|
|
|
|
method: 'POST',
|
|
|
|
data,
|
|
|
|
headers: {
|
|
|
|
'Authorization': authKey,
|
|
|
|
'X-Localization': I18n.currentLocale()
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
console.log(response);
|
|
|
|
dispatch(fetchCasserEpargneUserSuccess(response));
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
if (error.response)
|
|
|
|
dispatch(fetchCasserEpargneUserError(error.response));
|
|
|
|
else if (error.request)
|
|
|
|
dispatch(fetchCasserEpargneUserError(error.request))
|
|
|
|
else
|
|
|
|
dispatch(fetchCasserEpargneUserError(error.message))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const casserEpargneUserReset = () => {
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchCasserEpargneUserReset());
|
|
|
|
}
|
2020-09-30 05:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const getNanoCreditAccountAction = (idUser) => {
|
|
|
|
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchGetNanoCreditUserAccountPending());
|
|
|
|
|
|
|
|
axios({
|
|
|
|
url: `${getNanoCreditAccount}/${idUser}`,
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'Authorization': authKey,
|
|
|
|
'X-Localization': I18n.currentLocale()
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
console.log(response);
|
|
|
|
dispatch(fetchGetNanoCreditUserAccountSuccess(response));
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
if (error.response)
|
|
|
|
dispatch(fetchGetNanoCreditUserAccountError(error.response));
|
|
|
|
else if (error.request)
|
|
|
|
dispatch(fetchGetNanoCreditUserAccountError(error.request))
|
|
|
|
else
|
|
|
|
dispatch(fetchGetNanoCreditUserAccountError(error.message))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getNanoCreditAccountReset = () => {
|
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchGetNanoCreditUserAccountReset());
|
|
|
|
}
|
2020-08-12 18:24:56 +00:00
|
|
|
}
|