How to use the react-toastify.toast.success function in react-toastify

To help you get started, we’ve selected a few react-toastify 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 BigDataBoutique / ElastiQuill / admin-frontend / src / pages / ItemFormPage.js View on Github external
async _onSubmit(formValues) {
    const store = this.store;
    const save = this._isNew()
      ? this.createItem
      : this.updateItem.bind(this, store.currentItem.id);

    this.store.setFormSaving(true);
    try {
      const resp = await save(formValues);

      if (this._isNew()) {
        this.props.history.replace("/edit/" + this._getType() + "/" + resp.id);
      }

      toast.success("Changes saved");
      this.store.setFormModalOpen(false);
      this.store.setCurrentItem(formValues);
    } catch (err) {
      console.log(err);
      let errorMsg = err.message;
      if (err.message === "Conflict") {
        errorMsg = "Page with that name already exists";
      }
      toast.error(errorMsg);
    } finally {
      this.store.setFormSaving(false);
    }
  }
}
github johndatserakis / koa-react-notes-web / src / components / User / Signup.js View on Github external
let form = document.getElementById('submit-form')

        if (!form.checkValidity()) {
            toast.error('Please complete all fields.')
            return
        }

        try {
            await this.props.userActionSignup({
                firstName: this.state.firstName,
                lastName: this.state.lastName,
                username: this.state.username,
                email: this.state.email,
                password: this.state.password
            })
            toast.success('Successfully signed up. Please login.');
            this.props.history.push('/user/login')
        } catch (error) {
            console.log(error.message)
            if (!error.message) {
                toast.error('There was an error connecting to the server. Please try again.')
            } else if (error.message === 'DUPLICATE_USERNAME') {
                toast.error('Hmm, that username is already in use. Please try another one.')
            } else if (error.message === 'DUPLICATE_EMAIL') {
                toast.error('Hmm, that email is already in use. Please try another one.')
            } else {
                toast.error('There was an error connecting to the server. Please try again.')
            }
        }
    }
github theRoughCode / WatsMyMajor / react-ui / src / components / settings / ImageUpload.jsx View on Github external
"x-secret": process.env.REACT_APP_SERVER_SECRET,
        }
      });


      if (!response.ok) {
        toast.error('Failed to upload image.  Please contact an administrator.');
        this.setState({ loading: false });
        return;
      }

      const user = await response.json();
      this.props.onChangeImage(this.props.username, user);
      this.setState({ loading: false });
      this.closeDialog();
      toast.success('Image upload success!');
    } catch(err) {
      console.error(err);
      this.setState({ loading: false });
    }
  }
github moltin / gatsby-demo-store / src / context / CartContext.js View on Github external
async function updateQuantity(id, quantity) {
    const payload = await moltin.put(`carts/${cartId}/items/${id}`, {
      type: 'cart_item',
      id,
      quantity
    })

    dispatch({ type: SET_CART, payload })

    toast.success(`Quantity updated to ${quantity}`)
  }
github llambda / agilegps / src / client / components / organizations.js View on Github external
.then(() => {
            toast.success(`Org ${org.name} deleted.`);
          })
          .catch(err => {
github Lambda-School-Labs / LabsPT1_bkwds / client / src / redux / actions / settings.js View on Github external
.then(res => {
      const user = res.data
      dispatch({ type: UPDATE_SETTINGS_SUCCESS })
      dispatch({ type: UPDATE_USER_IN_STORE, payload: user })
      toast.success(msg, {
        position: toast.POSITION.BOTTOM_RIGHT
      })
      dispatch({ type: CLOSE_MODAL })
    })
    .catch(err => {
github liorchamla / formation-api-platform-react / assets / js / pages / CustomersPage.jsx View on Github external
const handleDelete = async id => {
    const originalCustomers = [...customers];
    setCustomers(customers.filter(customer => customer.id !== id));

    try {
      await CustomersAPI.delete(id);
      toast.success("Le client a bien été supprimé");
    } catch (error) {
      setCustomers(originalCustomers);
      toast.error("La suppression du client n'a pas pu fonctionner");
    }
  };
github ThomasRoest / better-bookmarks / src / components / EditBookmarkForm / index.js View on Github external
event.preventDefault();
    let errors = [];
    if (bookmark && bookmark.title === "") {
      errors.push({ name: "title", msg: "cant be empty" });
    }
    if (bookmark && bookmark.url === "") {
      errors.push({ name: "url", msg: "cant be empty" });
    }
    setErrors(errors);
    const isValid = errors.length === 0;

    if (bookmark && isValid) {
      const { id, title, url, tag, userId, pinned } = bookmark;
      bookmarks.updateBookmark({ id, title, url, tag, userId, pinned });
      history.push("/");
      toast.success("updated bookmark");
    }
  };
github startups-services / epic-admin-dashboard / utils / toastActions.js View on Github external
export const realDataMsg = () => {
  toast.success(
    <>
      {'It\'s a real data.'}
      <br>
      Your changes have been saved successfully
    ,
    {
      bodyClassName: 'toast__real-data',
      className: 'toast__real-data',
      progressClassName: 'real-data__progressbar',
    },
  );
};
github nomadcoders / prismagram-frontend / src / Routes / Auth / AuthContainer.js View on Github external
const onSubmit = async e => {
    e.preventDefault();
    if (action === "logIn") {
      if (email.value !== "") {
        try {
          const {
            data: { requestSecret }
          } = await requestSecretMutation();
          if (!requestSecret) {
            toast.error("You dont have an account yet, create one");
            setTimeout(() => setAction("signUp"), 3000);
          } else {
            toast.success("Check your inbox for your login secret");
            setAction("confirm");
          }
        } catch {
          toast.error("Can't request secret, try again");
        }
      } else {
        toast.error("Email is required");
      }
    } else if (action === "signUp") {
      if (
        email.value !== "" &&
        username.value !== "" &&
        firstName.value !== "" &&
        lastName.value !== ""
      ) {
        try {