connected-react-router#replace JavaScript Examples

The following examples show how to use connected-react-router#replace. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From HexactaLabs-NetCore_React-Final with Apache License 2.0 6 votes vote down vote up
export function create(product) {
  return function (dispatch) {
    dispatch(setLoading(true));
    return api
      .post(`/product/`, product)
      .then((response) => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(response.data.data));
        dispatch(setLoading(false));
        toast.success("El producto se creó con éxito");
        
        return dispatch(replace("/product"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #2
Source File: auth.actions.js    From mern-stack with MIT License 6 votes vote down vote up
signInSuccess = (payload, successType) => (
  dispatch,
  getState,
  { mernApi }
) => {
  setAuthInfo(payload, mernApi);
  dispatch({ type: successType, payload });
  if (getState().auth.attemptedPath) {
    dispatch(replace(getState().auth.attemptedPath));
    dispatch(setAttemptedPath(null));
  }
}
Example #3
Source File: index.js    From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 6 votes vote down vote up
export function remove(id) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .delete(`/producttype/${id}`)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(id));
        dispatch(setLoading(false));
        toast.success("Se eliminó el tipo de producto con éxito");
        
        return dispatch(replace("/producttype"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #4
Source File: index.js    From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 6 votes vote down vote up
export function create(producttype) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .post(`/producttype/`, producttype)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(response.data.data));
        dispatch(setLoading(false));
        toast.success("El tipo de producto se creó con éxito");
        
        return dispatch(replace("/producttype"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #5
Source File: index.js    From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 6 votes vote down vote up
export function create(store) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .post(`/store/`, store)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(response.data.data));
        dispatch(setLoading(false));
        toast.success("La tienda se creó con éxito");
        
        return dispatch(replace("/store"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #6
Source File: index.js    From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 6 votes vote down vote up
export function create(provider) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .post(`/provider/`, provider)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(response.data.data));
        dispatch(setLoading(false));
        toast.success("El proveedor se creó con éxito");
        
        return dispatch(replace("/provider"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #7
Source File: index.js    From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 6 votes vote down vote up
export function remove(id) {
  return function (dispatch) {
    dispatch(setLoading(true));
    return api
      .delete(`/producttype/${id}`)
      .then((response) => {
        if (!response.data.success) {
          var error = {
            response: { data: { Message: response.data.message } },
          };

          return handleError(dispatch, error);
        }

        dispatch(success(id));
        dispatch(setLoading(false));
        toast.success("Se eliminó el prodType con éxito");

        return dispatch(replace("/producttype"));
      })
      .catch((error) => {
        return handleError(dispatch, error);
      });
  };
}
Example #8
Source File: index.js    From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 6 votes vote down vote up
export function create(producttype) {
  return function (dispatch) {
    dispatch(setLoading(true));
    return api
      .post(`/producttype/`, producttype)
      .then((response) => {
        if (!response.data.success) {
          var error = {
            response: { data: { Message: response.data.message } },
          };

          return handleError(dispatch, error);
        }

        dispatch(success(response.data.data));
        dispatch(setLoading(false));
        toast.success("El tipo de producto se creó con éxito");

        return dispatch(replace("/producttype"));
      })
      .catch((error) => {
        return handleError(dispatch, error);
      });
  };
}
Example #9
Source File: index.js    From HexactaLabs-NetCore_React-Final with Apache License 2.0 6 votes vote down vote up
export function remove(id) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .delete(`/product/${id}`)
      .then((response) => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(id));
        dispatch(setLoading(false));
        toast.success("Se eliminó el producto con éxito");
        
        return dispatch(replace("/product"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #10
Source File: index.js    From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 6 votes vote down vote up
export function remove(id) {
  return function (dispatch) {
    dispatch(setLoading(true));
    return api
      .delete(`/store/${id}`)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(id));
        dispatch(setLoading(false));
        toast.success("Se eliminó la tienda con éxito");
        
        return dispatch(replace("/store"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #11
Source File: index.js    From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 6 votes vote down vote up
export function create(store) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .post(`/store/`, store)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(response.data.data));
        dispatch(setLoading(false));
        toast.success("La tienda se creó con éxito");
        
        return dispatch(replace("/store"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #12
Source File: index.js    From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 6 votes vote down vote up
export function remove(id) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .delete(`/provider/${id}`)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(id));
        dispatch(setLoading(false));
        toast.success("Se eliminó el proveedor con éxito");
        
        return dispatch(replace("/provider"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #13
Source File: index.js    From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 6 votes vote down vote up
export function create(provider) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .post(`/provider/`, provider)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(response.data.data));
        dispatch(setLoading(false));
        toast.success("El proveedor se creó con éxito");
        
        return dispatch(replace("/provider"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #14
Source File: index.js    From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 6 votes vote down vote up
export function remove(id) {
  return function (dispatch) {
    dispatch(setLoading(true));
    return api
      .delete(`/producttype/${id}`)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(id));
        dispatch(setLoading(false));
        toast.success("El tipo se eliminó con éxito");
        
        return dispatch(replace("/product-type"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #15
Source File: index.js    From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 6 votes vote down vote up
export function create(productType) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .post(`/producttype/`, productType)
      .then(response => {
        if (!response.data.success) {
          var error = {response: {data: {Message: response.data.message}}};

          return handleError(dispatch, error);
        }

        dispatch(success(response.data.data));
        dispatch(setLoading(false));
        toast.success("El nuevo tipo se creó con exito");
        
        return dispatch(replace("/product-type"));
      })
      .catch(error => {
        return handleError(dispatch, error);
      });
  };
}
Example #16
Source File: index.js    From HexactaLabs-NetCore_React-Initial with Apache License 2.0 6 votes vote down vote up
export function remove(id) {
  return function (dispatch) {
    dispatch(setLoading(true));
    return api
      .delete(`/store/${id}`)
      .then(response => {
        if (response.status !== OK_STATUS) {
          toast.error(response.data.message);
          dispatch(setLoading(false));
          return dispatch(replace("/store"));
        }

        toast.success("Se eliminó la tienda con éxito");
        dispatch(success(id));
        dispatch(replace("/store"));
        return dispatch(setLoading(false));
      })
      .catch(error => {
        apiErrorToast(error);
        return dispatch(setLoading(false));
      });
  };
}
Example #17
Source File: index.js    From HexactaLabs-NetCore_React-Initial with Apache License 2.0 6 votes vote down vote up
export function remove(id) {
  return function(dispatch) {
    dispatch(setLoading(true));
    return api
      .delete(`/provider/${id}`)
      .then(response => {
        if (!response.data.success) {
          toast.error(response.data.message);
          dispatch(setLoading(false));
          return dispatch(replace("/provider"));
        }

        toast.success("Se eliminó el proveedor con éxito");
        dispatch(success(id));
        dispatch(setLoading(false));
        return dispatch(replace("/provider"));
      })
      .catch(error => {
        apiErrorToast(error);
        return dispatch(setLoading(false));
      });
  };
}
Example #18
Source File: index.js    From HexactaLabs-NetCore_React-Initial with Apache License 2.0 5 votes vote down vote up
logout = () => dispatch => {
  localStorage.removeItem("JWT_LOGIN");
  dispatch(replace("/"));
  window.location.reload();
}