2020-04-14 12:34:14 +00:00
|
|
|
import { createReducer } from "utils/AppsmithUtils";
|
|
|
|
|
import {
|
|
|
|
|
ReduxAction,
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxActionErrorTypes,
|
|
|
|
|
} from "constants/ReduxActionConstants";
|
|
|
|
|
|
|
|
|
|
const initialState: ImportReduxState = {
|
|
|
|
|
isImportingCurl: false,
|
|
|
|
|
errorPayload: {},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const importReducer = createReducer(initialState, {
|
|
|
|
|
[ReduxActionTypes.SUBMIT_CURL_FORM_INIT]: (state: ImportReduxState) => {
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
isImportingCurl: true,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
[ReduxActionTypes.SUBMIT_CURL_FORM_SUCCESS]: (state: ImportReduxState) => ({
|
|
|
|
|
...state,
|
|
|
|
|
isImportingCurl: false,
|
|
|
|
|
}),
|
|
|
|
|
[ReduxActionErrorTypes.SUBMIT_CURL_FORM_ERROR]: (
|
|
|
|
|
state: ImportReduxState,
|
|
|
|
|
action: ReduxAction<{ errorPayload: string }>,
|
|
|
|
|
) => {
|
|
|
|
|
return { ...state, errorPayload: action.payload, isImportingCurl: false };
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export interface ImportReduxState {
|
|
|
|
|
isImportingCurl: boolean;
|
2020-11-03 13:05:40 +00:00
|
|
|
errorPayload: Record<string, unknown>;
|
2020-04-14 12:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default importReducer;
|