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

142 lines
2.7 KiB
TypeScript
Raw Normal View History

2020-02-07 02:32:52 +00:00
import { RestAction, PaginationField } from "api/ActionAPI";
2020-01-24 09:54:40 +00:00
import {
ReduxActionTypes,
ReduxAction,
ReduxActionErrorTypes,
} from "constants/ReduxActionConstants";
2019-10-21 15:12:45 +00:00
2019-11-13 07:34:59 +00:00
export const createActionRequest = (payload: Partial<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 type FetchActionsPayload = {
2020-01-24 09:54:40 +00:00
applicationId: string;
};
export const fetchActions = (
2020-01-24 09:54:40 +00:00
applicationId: string,
): ReduxAction<FetchActionsPayload> => {
2019-10-21 15:12:45 +00:00
return {
type: ReduxActionTypes.FETCH_ACTIONS_INIT,
2020-01-24 09:54:40 +00:00
payload: { applicationId },
2019-10-21 15:12:45 +00:00
};
};
2020-02-07 02:32:52 +00:00
export const runApiAction = (id: string, paginationField?: PaginationField) => {
2019-10-21 15:12:45 +00:00
return {
2019-11-20 10:57:05 +00:00
type: ReduxActionTypes.RUN_API_REQUEST,
2020-02-07 02:32:52 +00:00
payload: {
id: id,
paginationField: paginationField,
},
};
};
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,
};
};
2020-01-24 09:54:40 +00:00
export const moveActionRequest = (payload: {
id: string;
destinationPageId: string;
originalPageId: string;
name: string;
}) => {
return {
type: ReduxActionTypes.MOVE_ACTION_INIT,
payload,
};
};
2020-01-27 13:53:33 +00:00
export const moveActionSuccess = (payload: RestAction) => {
2020-01-24 09:54:40 +00:00
return {
type: ReduxActionTypes.MOVE_ACTION_SUCCESS,
payload,
};
};
export const moveActionError = (payload: {
id: string;
originalPageId: string;
}) => {
return {
type: ReduxActionErrorTypes.MOVE_ACTION_ERROR,
payload,
};
};
export const copyActionRequest = (payload: {
id: string;
destinationPageId: string;
name: string;
}) => {
return {
type: ReduxActionTypes.COPY_ACTION_INIT,
payload,
};
};
export const copyActionSuccess = (payload: {
id: string;
destinationPageId: string;
}) => {
return {
type: ReduxActionTypes.COPY_ACTION_SUCCESS,
payload,
};
};
export const copyActionError = (payload: {
id: string;
destinationPageId: string;
}) => {
return {
type: ReduxActionErrorTypes.COPY_ACTION_ERROR,
payload,
};
};
2019-10-21 15:12:45 +00:00
export default {
createAction: createActionRequest,
2019-10-21 15:12:45 +00:00
fetchActions,
2019-11-20 10:57:05 +00:00
runAction: runApiAction,
2019-10-21 15:12:45 +00:00
deleteAction,
deleteActionSuccess,
updateAction,
updateActionSuccess,
2019-10-21 15:12:45 +00:00
};