2020-12-09 07:06:02 +00:00
|
|
|
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;
|
2020-06-17 10:19:56 +00:00
|
|
|
orgId: string;
|
2020-12-09 07:06:02 +00:00
|
|
|
colorCode?: AppColorCode;
|
|
|
|
|
appName?: AppIconName;
|
2019-12-16 08:49:10 +00:00
|
|
|
};
|
|
|
|
|
|
2020-10-08 10:32:31 +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> => {
|
2020-06-17 10:19:56 +00:00
|
|
|
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,
|
2020-06-17 10:19:56 +00:00
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
};
|