2019-10-21 15:12:45 +00:00
|
|
|
import { ReduxActionTypes } from "../constants/ReduxActionConstants";
|
|
|
|
|
import { RestAction } from "../api/ActionAPI";
|
|
|
|
|
|
|
|
|
|
export const createAction = (payload: RestAction) => {
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const fetchApiConfig = (payload: { id: string }) => {
|
|
|
|
|
return {
|
|
|
|
|
type: ReduxActionTypes.FETCH_ACTION,
|
|
|
|
|
payload,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const runAction = (payload: { id: string }) => {
|
|
|
|
|
return {
|
2019-10-25 05:35:20 +00:00
|
|
|
type: ReduxActionTypes.RUN_ACTION_INIT,
|
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
createAction,
|
|
|
|
|
fetchActions,
|
|
|
|
|
fetchApiConfig,
|
|
|
|
|
runAction,
|
|
|
|
|
deleteAction,
|
2019-10-25 05:35:20 +00:00
|
|
|
deleteActionSuccess,
|
|
|
|
|
updateAction,
|
|
|
|
|
updateActionSuccess,
|
2019-10-21 15:12:45 +00:00
|
|
|
};
|