PromucFlow_constructor/app/client/src/pages/Applications/helpers.ts

33 lines
902 B
TypeScript
Raw Normal View History

import { AppIconName } from "components/ads/AppIcon";
import { AppColorCode } from "constants/DefaultTheme";
2019-12-16 08:49:10 +00:00
import { ReduxActionTypes } from "constants/ReduxActionConstants";
import { SubmissionError } from "redux-form";
export type CreateApplicationFormValues = {
applicationName: string;
orgId: string;
colorCode?: AppColorCode;
appName?: AppIconName;
2019-12-16 08:49:10 +00:00
};
export const CREATE_APPLICATION_FORM_NAME_FIELD = "applicationName";
2019-12-16 08:49:10 +00:00
export const createApplicationFormSubmitHandler = (
values: CreateApplicationFormValues,
dispatch: any,
): Promise<any> => {
const { applicationName, orgId } = values;
2019-12-16 08:49:10 +00:00
return new Promise((resolve, reject) => {
dispatch({
type: ReduxActionTypes.CREATE_APPLICATION_INIT,
payload: {
resolve,
reject,
applicationName,
orgId,
2019-12-16 08:49:10 +00:00
},
});
2020-12-24 04:32:25 +00:00
}).catch((error) => {
2019-12-16 08:49:10 +00:00
throw new SubmissionError(error);
});
};