709 lines
23 KiB
JavaScript
709 lines
23 KiB
JavaScript
import {store} from "../../redux/store";
|
|
import axios from "axios";
|
|
import {
|
|
getAvisImpositionUrl,
|
|
getAvisImpositionWithoutOrdreRecetteUrl,
|
|
getAvisImpositionWithPenaliteUrl,
|
|
getOrdreRecetteUrl,
|
|
getOrdreRecetteWithoutQuitanceUrl,
|
|
getQRCodeDetail,
|
|
modifyAvisImpositionUrl,
|
|
modifyOrdreRecetteUrl,
|
|
modifyQuitanceUrl,
|
|
penalityUrl,
|
|
saveActifSocietyUrl,
|
|
saveOrdreRecetteUrl,
|
|
saveQuitanceUrl, searchUserHomeUrl,
|
|
searchUserUrl
|
|
} from "../IlinkConstants";
|
|
import I18n from "react-native-i18n";
|
|
import {
|
|
fetchDeletePenalityError,
|
|
fetchDeletePenalityPending,
|
|
fetchDeletePenalityReset,
|
|
fetchDeletePenalitySuccess,
|
|
fetchGetAvisImpossitionError,
|
|
fetchGetAvisImpossitionPending,
|
|
fetchGetAvisImpossitionReset,
|
|
fetchGetAvisImpossitionSuccess,
|
|
fetchGetAvisImpossitionWithPenaliteError,
|
|
fetchGetAvisImpossitionWithPenalitePending,
|
|
fetchGetAvisImpossitionWithPenaliteReset,
|
|
fetchGetAvisImpossitionWithPenaliteSuccess,
|
|
fetchGetQRCodeDetailError,
|
|
fetchGetQRCodeDetailPending,
|
|
fetchGetQRCodeDetailReset,
|
|
fetchGetQRCodeDetailSuccess,
|
|
fetchModifyAvisImpositionError,
|
|
fetchModifyAvisImpositionPending,
|
|
fetchModifyAvisImpositionReset,
|
|
fetchModifyAvisImpositionSuccess,
|
|
fetchModifyPenalityError,
|
|
fetchModifyPenalityPending,
|
|
fetchModifyPenalitySuccess,
|
|
fetchSaveActifSocietyError,
|
|
fetchSaveActifSocietyPending,
|
|
fetchSaveActifSocietyReset,
|
|
fetchSaveActifSocietySuccess,
|
|
fetchSavePenalityError,
|
|
fetchSavePenalityPending,
|
|
fetchSavePenalityReset,
|
|
fetchSavePenalitySuccess,
|
|
fetchSearchUserError,
|
|
fetchSearchUserPending,
|
|
fetchSearchUserReset,
|
|
fetchSearchUserSuccess
|
|
} from "../../redux/actions/WalletActions";
|
|
|
|
export const getAvisImpositionAction = (codeAgent) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionPending());
|
|
|
|
axios({
|
|
url: `${getAvisImpositionUrl}/${codeAgent}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetAvisImpossitionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetAvisImpossitionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetAvisImpossitionError(error.request))
|
|
else
|
|
dispatch(fetchGetAvisImpossitionError(error.message))
|
|
});
|
|
}
|
|
}
|
|
|
|
export const getAvisImpositionWithPenalityAction = (codeAgent) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionWithPenalitePending());
|
|
|
|
axios({
|
|
url: `${getAvisImpositionWithPenaliteUrl}/${codeAgent}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetAvisImpossitionWithPenaliteSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetAvisImpossitionWithPenaliteError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetAvisImpossitionWithPenaliteError(error.request))
|
|
else
|
|
dispatch(fetchGetAvisImpossitionWithPenaliteError(error.message))
|
|
});
|
|
}
|
|
}
|
|
export const getAvisImpositionWithPenalityReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionWithPenaliteReset());
|
|
}
|
|
}
|
|
|
|
export const getAvisImpositionWithoutOrdreRecetteAction = (codeAgent) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionPending());
|
|
|
|
axios({
|
|
url: `${getAvisImpositionWithoutOrdreRecetteUrl}/${codeAgent}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetAvisImpossitionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetAvisImpossitionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetAvisImpossitionError(error.request))
|
|
else
|
|
dispatch(fetchGetAvisImpossitionError(error.message))
|
|
});
|
|
}
|
|
}
|
|
export const getAvisImpositionReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionReset());
|
|
}
|
|
}
|
|
|
|
export const modifyvisImpositionAction = (data) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchModifyAvisImpositionPending());
|
|
|
|
axios({
|
|
url: `${modifyAvisImpositionUrl}`,
|
|
method: 'POST',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchModifyAvisImpositionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchModifyAvisImpositionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchModifyAvisImpositionError(error.request))
|
|
else
|
|
dispatch(fetchModifyAvisImpositionError(error.message))
|
|
});
|
|
}
|
|
}
|
|
export const modifyAvisImpositionReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchModifyAvisImpositionReset());
|
|
}
|
|
}
|
|
|
|
export const saveOrdreRecetteAction = (data) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchModifyAvisImpositionPending());
|
|
|
|
axios({
|
|
url: `${saveOrdreRecetteUrl}`,
|
|
method: 'POST',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchModifyAvisImpositionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchModifyAvisImpositionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchModifyAvisImpositionError(error.request));
|
|
else
|
|
dispatch(fetchModifyAvisImpositionError(error.message));
|
|
});
|
|
}
|
|
}
|
|
|
|
export const saveQuitanceAction = (data, pay = false) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchModifyAvisImpositionPending());
|
|
|
|
axios({
|
|
url: `${pay ? saveQuitanceUrl + '/pay' : saveQuitanceUrl}`,
|
|
method: 'POST',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchModifyAvisImpositionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchModifyAvisImpositionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchModifyAvisImpositionError(error.request));
|
|
else
|
|
dispatch(fetchModifyAvisImpositionError(error.message));
|
|
});
|
|
}
|
|
}
|
|
|
|
export const modifyOrdreRecetteAction = (id, data) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchModifyAvisImpositionPending());
|
|
|
|
axios({
|
|
url: `${modifyOrdreRecetteUrl}/${id}`,
|
|
method: 'PUT',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchModifyAvisImpositionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchModifyAvisImpositionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchModifyAvisImpositionError(error.request));
|
|
else
|
|
dispatch(fetchModifyAvisImpositionError(error.message));
|
|
});
|
|
}
|
|
}
|
|
|
|
export const modifyQuitanceAction = (id, data) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchModifyAvisImpositionPending());
|
|
console.log("ITEM", id);
|
|
axios({
|
|
url: `${modifyQuitanceUrl}/${id}`,
|
|
method: 'PUT',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchModifyAvisImpositionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchModifyAvisImpositionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchModifyAvisImpositionError(error.request));
|
|
else
|
|
dispatch(fetchModifyAvisImpositionError(error.message));
|
|
});
|
|
}
|
|
}
|
|
|
|
export const getQuitanceAction = (codeAgent) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionPending());
|
|
|
|
axios({
|
|
url: `${saveQuitanceUrl}/${codeAgent}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetAvisImpossitionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetAvisImpossitionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetAvisImpossitionError(error.request))
|
|
else
|
|
dispatch(fetchGetAvisImpossitionError(error.message))
|
|
});
|
|
}
|
|
}
|
|
export const getOrdreRecetteWithoutQuitanceAction = (codeAgent, refresh = 0) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionPending());
|
|
|
|
axios({
|
|
url: `${getOrdreRecetteWithoutQuitanceUrl}/${codeAgent}?refresh=${refresh}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetAvisImpossitionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetAvisImpossitionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetAvisImpossitionError(error.request))
|
|
else
|
|
dispatch(fetchGetAvisImpossitionError(error.message))
|
|
});
|
|
}
|
|
}
|
|
export const getOrdreRecetteAction = (codeAgent) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionPending());
|
|
|
|
axios({
|
|
url: `${getOrdreRecetteUrl}/${codeAgent}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetAvisImpossitionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetAvisImpossitionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetAvisImpossitionError(error.request))
|
|
else
|
|
dispatch(fetchGetAvisImpossitionError(error.message))
|
|
});
|
|
}
|
|
}
|
|
export const getOrdreRecetteReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionReset());
|
|
}
|
|
}
|
|
|
|
export const getOrdreRecetteDetailAction = (idRevenue) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionPending());
|
|
|
|
axios({
|
|
url: `${saveOrdreRecetteUrl}/${idRevenue}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetAvisImpossitionSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetAvisImpossitionError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetAvisImpossitionError(error.request));
|
|
else
|
|
dispatch(fetchGetAvisImpossitionError(error.message));
|
|
});
|
|
}
|
|
}
|
|
export const getOrdreRecetteDetailReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchGetAvisImpossitionReset());
|
|
}
|
|
};
|
|
|
|
export const saveActifSocietyAction = (data) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchSaveActifSocietyPending());
|
|
|
|
axios({
|
|
url: `${saveActifSocietyUrl}`,
|
|
method: 'POST',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchSaveActifSocietySuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchSaveActifSocietyError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchSaveActifSocietyError(error.request));
|
|
else
|
|
dispatch(fetchSaveActifSocietyError(error.message));
|
|
});
|
|
}
|
|
}
|
|
export const saveActifSocietyReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchSaveActifSocietyReset());
|
|
}
|
|
};
|
|
|
|
export const modifyPenalityAction = (idPenality, data) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchModifyPenalityPending());
|
|
|
|
axios({
|
|
url: `${penalityUrl}/${idPenality}`,
|
|
method: 'PUT',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchModifyPenalitySuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchModifyPenalityError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchModifyPenalityError(error.request));
|
|
else
|
|
dispatch(fetchModifyPenalityError(error.message));
|
|
});
|
|
}
|
|
}
|
|
export const modifyPenalityReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchSaveActifSocietyReset());
|
|
}
|
|
};
|
|
|
|
export const deletePenalityAction = (idPenality, data) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchDeletePenalityPending());
|
|
|
|
axios({
|
|
url: `${penalityUrl}/${idPenality}`,
|
|
method: 'DELETE',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchDeletePenalitySuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchDeletePenalityError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchDeletePenalityError(error.request));
|
|
else
|
|
dispatch(fetchDeletePenalityError(error.message));
|
|
});
|
|
}
|
|
}
|
|
export const deletePenalityReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchDeletePenalityReset());
|
|
}
|
|
};
|
|
|
|
export const savePenalityAction = (data) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchSavePenalityPending());
|
|
|
|
axios({
|
|
url: `${penalityUrl}`,
|
|
method: 'POST',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchSavePenalitySuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchSavePenalityError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchSavePenalityError(error.request));
|
|
else
|
|
dispatch(fetchSavePenalityError(error.message));
|
|
});
|
|
}
|
|
}
|
|
export const savePenalityReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchSavePenalityReset());
|
|
}
|
|
};
|
|
|
|
export const searchUserAction = (data, searchFromMap = false) => {
|
|
console.log("searchUserAction===>>", data, searchFromMap);
|
|
console.log("searchUserActionUrl===>>", searchFromMap ? searchUserHomeUrl : `${searchUserUrl}?name=${data}`);
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchSearchUserPending());
|
|
|
|
axios({
|
|
url: searchFromMap ? searchUserHomeUrl : `${searchUserUrl}?name=${data}`,
|
|
method: searchFromMap ? 'POST' : 'GET',
|
|
data,
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchSearchUserSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchSearchUserError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchSearchUserError(error.request));
|
|
else
|
|
dispatch(fetchSearchUserError(error.message));
|
|
});
|
|
}
|
|
}
|
|
export const searchUserReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchSearchUserReset());
|
|
}
|
|
};
|
|
|
|
export const getQRCodeDetailAction = (id) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return dispatch => {
|
|
dispatch(fetchGetQRCodeDetailPending());
|
|
|
|
axios({
|
|
url: `${getQRCodeDetail}/${id}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
}
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
dispatch(fetchGetQRCodeDetailSuccess(response));
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
dispatch(fetchGetQRCodeDetailError(error.response));
|
|
else if (error.request)
|
|
dispatch(fetchGetQRCodeDetailError(error.request));
|
|
else
|
|
dispatch(fetchGetQRCodeDetailError(error.message));
|
|
});
|
|
}
|
|
}
|
|
export const getQRCodeDetailReset = () => {
|
|
return dispatch => {
|
|
dispatch(fetchGetQRCodeDetailReset());
|
|
}
|
|
};
|
|
|
|
export const fetchRecalculatePenality = (idPenality) => {
|
|
|
|
const auth = store.getState().authKeyReducer;
|
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
|
|
|
return new Promise(async (resolve, reject) => {
|
|
axios({
|
|
url: `${penalityUrl}/recalculate/${idPenality}`,
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': authKey,
|
|
'X-Localization': I18n.currentLocale()
|
|
},
|
|
})
|
|
.then(response => {
|
|
console.log(response);
|
|
resolve(response);
|
|
})
|
|
.catch(error => {
|
|
if (error.response)
|
|
reject(error.response);
|
|
else if (error.request)
|
|
reject(error.request);
|
|
else
|
|
reject(error.message);
|
|
});
|
|
});
|
|
}
|