diff --git a/frontend/src/actions/cartActions.js b/frontend/src/actions/cartActions.js index bd69be4..92fd218 100644 --- a/frontend/src/actions/cartActions.js +++ b/frontend/src/actions/cartActions.js @@ -6,22 +6,25 @@ const addToCart = (productId, qty) => async (dispatch, getState) => { try { const { data } = await Axios.get("/api/products/" + productId); dispatch({ - type: CART_ADD_ITEM, payload: { + type: CART_ADD_ITEM, + payload: { product: data._id, name: data.name, image: data.image, price: data.price, countInStock: data.countInStock, - qty - } + qty, + }, }); - const { cart: { cartItems } } = getState(); + const { + cart: { cartItems }, + } = getState(); Cookie.set("cartItems", JSON.stringify(cartItems)); - } catch (error) { - + } -} +}; + const removeFromCart = (productId) => (dispatch, getState) => { dispatch({ type: CART_REMOVE_ITEM, payload: productId });