simba-mobile-cud/app/redux/historic/historic.actions.js

73 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2025-01-07 09:47:45 +00:00
import {testBaseUrl} from "../../webservice/IlinkConstants";
import HistoricActions from "./historic.type";
import {ApiAction} from "../reducers";
/************************************************************/
export const fetchGetHistoricPending = () => ({
type: HistoricActions.GET_HISTORY_PENDING
});
export const fetchGeHistoricReset = () => ({
type: HistoricActions.GET_HISTORY_RESET,
});
export const fetchGetHistoricSuccess = (authkey) => ({
type: HistoricActions.GET_HISTORY_SUCCESS,
payload: authkey,
});
export const fetchGetHistoricError = (error) => ({
type: HistoricActions.GET_HISTORY_ERROR,
payload: error,
});
export const fetchGetHistoric = (walletID, isHyper, transactionType) => {
let url = "/walletService/history";
switch (isHyper) {
case true:
url += "/hyper";
break;
case false:
url += "/super";
break;
case null:
url += "/agent";
break;
}
switch (transactionType) {
case 0:
url += "";
break;
case 1:
url += "/tax_notices";
break;
case 2:
if (isHyper)
url += "/revenue_orders";
else
url += "/orders_receipts";
break;
case 3:
url += "/receipts";
break;
}
return ApiAction({
url: `${testBaseUrl + url}/${walletID}`,
method: 'GET',
onLoading: fetchGetHistoricPending,
onSuccess: fetchGetHistoricSuccess,
onError: fetchGetHistoricError,
});
};