How to use the redux-form.stopSubmit function in redux-form

To help you get started, we’ve selected a few redux-form examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oreqizer / reactizer-2016 / src / universal / modules / user / __tests__ / userSagas.spec.js View on Github external
// api call
    const request = saga.next().value;
    expect(request).toEqual(call(userApi.register, payload));

    // api error
    const error = 'error';
    const response = saga.throw({ data: error }).value;
    expect(response).toEqual(put({
      type: REGISTER_ERROR,
      payload: { error },
    }));

    // stop form submit
    const stoppedSubmit = saga.next().value;
    expect(stoppedSubmit).toEqual(put(stopSubmit(REGISTER)));
  });
});
github bpetetot / conference-hall / src / sagas / events / events.saga.js View on Github external
const FORM = 'event-create'
  try {
    // indicate start submitting form
    yield put(startSubmit(FORM))
    // get user id
    const uid = yield select(getUserId)
    // create event into database
    const ref = yield call(eventCrud.create, { ...event, owner: uid })
    // reset form
    yield put(reset(FORM))
    // set form submitted
    yield put(stopSubmit(FORM))
    // go to event page
    yield put(push(`/organizer/event/${ref.id}`))
  } catch (error) {
    yield put(stopSubmit(FORM, { _error: error.message }))
    throw error
  }
}
github atahani / reactjs-unsplash / src / sagas / collection.js View on Github external
export function* createCollectionF(): any {
  while (true) {
    const { collection } = yield take(CREATE_COLLECTION);
    yield all([
      put(jobStatus(true)),
      put(startSubmit('add_or_edit_collection')),
    ]);
    const { response, error } = yield call(createCollection, collection);
    yield all([
      put(jobStatus(false)),
      put(stopSubmit('add_or_edit_collection')),
    ]);
    if (response) {
      // update the entity
      // NOTE: the user collection locate in userCollections
      yield put(setItem('userCollections', response));
      // get current search path in url if startsWith ?add_to_collection&id=
      const { search } = getHistory().location;
      const searchParams = new URLSearchParams(search);
      if (searchParams.has('step') && searchParams.has('id')) {
        // get id from url
        yield put(push(`?add_to_collection&id=${searchParams.get('id')}`));
      } else {
        yield put(push(`/collections/${response.id}`));
      }
    } else {
      yield fork(handleCommonErr, error, CREATE_COLLECTION, { collection });
github bpetetot / conference-hall / src / sagas / events / events.saga.js View on Github external
function* createEvent(event) {
  const FORM = 'event-create'
  try {
    // indicate start submitting form
    yield put(startSubmit(FORM))
    // get user id
    const uid = yield select(getUserId)
    // create event into database
    const ref = yield call(eventCrud.create, { ...event, owner: uid })
    // reset form
    yield put(reset(FORM))
    // set form submitted
    yield put(stopSubmit(FORM))
    // go to event page
    yield put(push(`/organizer/event/${ref.id}`))
  } catch (error) {
    yield put(stopSubmit(FORM, { _error: error.message }))
    throw error
  }
}
github zhuyst / SkyBlog / client_web / src / action / article / ContentAction.js View on Github external
.then(result => {
            dispatch(setPreviousComment(initialPreviousComment));
            dispatch(stopSubmit(FORM_COMMENT,result.errors));

            if(result.code === 200){
                dispatch(success("新增评论成功"));
                dispatch(insertCommentResponse(result));

                reloadComments(dispatch,getState);
            }
            else {
                dispatch(error(result.message));
            }
        });
};
github stipsan / epic / src / client / sagas / socket.js View on Github external
export function *handleEmit(action) {
  yield put(socketRequest(action))
  yield take(action.type)
  yield put(startSubmit('login'))
  yield take([action.payload.successType, action.payload.failureType])
  yield put(stopSubmit('login'))
}
github Automattic / wp-calypso / client / extensions / zoninator / state / data-layer / feeds / index.js View on Github external
export const announceFailure = action => [
	stopSubmit( action.form ),
	errorNotice( translate( 'There was a problem saving your changes. Please try again' ), {
		id: saveFeedNotice,
	} ),
];
github zhuyst / SkyBlog / client_web / src / action / user / UsersAction.js View on Github external
.then(result => {
            dispatch(stopSubmit(FORM_REGISTER,result.errors));

            if(result.code === 200){
                dispatch(setRegisterModalShow(false));
                dispatch(success("注册成功,开始登录"));
                dispatch(registerUserResponse(result));
                afterLogin(result,dispatch,true);
            }
            else {
                dispatch(error(result.message));
            }
        })
};
github zhuyst / SkyBlog / client_web_refactor / action / article / article.ts View on Github external
return async (dispatch) => {
    dispatch(startSubmit(FORM_ARTICLE));

    const result = await fetchFunc();
    dispatch(stopSubmit(FORM_ARTICLE, result.errors));

    if (result.code === ApiResultCode.OK) {
      msg.success(successMsg);
      dispatch(articleResponseActionCreator(result.entity));

      dispatch(listArticles(1, ARTICLE_PAGE_SIZE));
      dispatch(listClassify());

      if (extraSuccessFunc) {
        await extraSuccessFunc(result);
      }
    } else {
      msg.error(result.message);
    }
  };
}
github webkom / lego-webapp / app / actions / CommentActions.js View on Github external
.catch(action => {
        const errors = { ...action.payload.response.jsonData };
        dispatch(stopSubmit('comment', errors));
      });
  };