PromucFlow_constructor/app/client/src/actions/actionActions.ts

76 lines
1.6 KiB
TypeScript
Raw Normal View History

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
export const createActionRequest = (payload: RestAction) => {
2019-10-21 15:12:45 +00:00
return {
type: ReduxActionTypes.CREATE_ACTION_INIT,
2019-10-21 15:12:45 +00:00
payload,
};
};
export const createActionSuccess = (payload: RestAction) => {
2019-10-21 15:12:45 +00:00
return {
type: ReduxActionTypes.CREATE_ACTION_SUCCESS,
payload,
2019-10-21 15:12:45 +00:00
};
};
export const fetchActions = () => {
2019-10-21 15:12:45 +00:00
return {
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,
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 {
type: ReduxActionTypes.DELETE_ACTION_INIT,
2019-10-21 15:12:45 +00:00
payload,
};
};
export const deleteActionSuccess = (payload: { id: string }) => {
2019-10-21 15:12:45 +00:00
return {
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 {
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,
deleteActionSuccess,
updateAction,
updateActionSuccess,
2019-10-21 15:12:45 +00:00
};