2019-10-21 15:12:45 +00:00
|
|
|
import { ReduxActionTypes } from "../constants/ReduxActionConstants";
|
|
|
|
|
import { RestAction } from "../api/ActionAPI";
|
2019-11-06 06:35:15 +00:00
|
|
|
import { ActionPayload } from "../constants/ActionConstants";
|
2019-10-21 15:12:45 +00:00
|
|
|
|
2019-10-29 12:02:58 +00:00
|
|
|
export const createActionRequest = (payload: RestAction) => {
|
2019-10-21 15:12:45 +00:00
|
|
|
return {
|
2019-10-25 05:35:20 +00:00
|
|
|
type: ReduxActionTypes.CREATE_ACTION_INIT,
|
2019-10-21 15:12:45 +00:00
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-25 05:35:20 +00:00
|
|
|
export const createActionSuccess = (payload: RestAction) => {
|
2019-10-21 15:12:45 +00:00
|
|
|
return {
|
2019-10-25 05:35:20 +00:00
|
|
|
type: ReduxActionTypes.CREATE_ACTION_SUCCESS,
|
|
|
|
|
payload,
|
2019-10-21 15:12:45 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-25 05:35:20 +00:00
|
|
|
export const fetchActions = () => {
|
2019-10-21 15:12:45 +00:00
|
|
|
return {
|
2019-10-25 05:35:20 +00:00
|
|
|
type: ReduxActionTypes.FETCH_ACTIONS_INIT,
|
2019-10-21 15:12:45 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-11-06 06:35:15 +00:00
|
|
|
export const executeAction = (payload: ActionPayload[]) => {
|
2019-10-21 15:12:45 +00:00
|
|
|
return {
|
2019-11-06 06:35:15 +00:00
|
|
|
type: ReduxActionTypes.EXECUTE_ACTION,
|
2019-10-25 05:35:20 +00:00
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const updateAction = (payload: { data: RestAction }) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_ACTION_INIT,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const updateActionSuccess = (payload: { data: RestAction }) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.UPDATE_ACTION_SUCCESS,
|
2019-10-21 15:12:45 +00:00
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const deleteAction = (payload: { id: string }) => {
|
|
|
|
|
return {
|
2019-10-25 05:35:20 +00:00
|
|
|
type: ReduxActionTypes.DELETE_ACTION_INIT,
|
2019-10-21 15:12:45 +00:00
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-25 05:35:20 +00:00
|
|
|
export const deleteActionSuccess = (payload: { id: string }) => {
|
2019-10-21 15:12:45 +00:00
|
|
|
return {
|
2019-10-25 05:35:20 +00:00
|
|
|
type: ReduxActionTypes.DELETE_ACTION_SUCCESS,
|
2019-10-21 15:12:45 +00:00
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-11-12 09:43:13 +00:00
|
|
|
export const dryRunAction = (payload: RestAction) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.DRY_RUN_ACTION,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-21 15:12:45 +00:00
|
|
|
export default {
|
2019-10-29 12:02:58 +00:00
|
|
|
createAction: createActionRequest,
|
2019-10-21 15:12:45 +00:00
|
|
|
fetchActions,
|
2019-11-06 06:35:15 +00:00
|
|
|
runAction: executeAction,
|
2019-10-21 15:12:45 +00:00
|
|
|
deleteAction,
|
2019-10-25 05:35:20 +00:00
|
|
|
deleteActionSuccess,
|
|
|
|
|
updateAction,
|
|
|
|
|
updateActionSuccess,
|
2019-10-21 15:12:45 +00:00
|
|
|
};
|