Skip to Content
Full-Stack React Projects - Second Edition
book

Full-Stack React Projects - Second Edition

by Shama Hoque
April 2020
Intermediate to advanced
716 pages
18h 55m
English
Packt Publishing
Content preview from Full-Stack React Projects - Second Edition

Handling the action to update the status of a product

If a seller chooses to update the status of an ordered product so that it has a value other than Cancelled or Processing, we will need to invoke an API that will update the order in the database with this changed product status. So, when a seller selects other status values from the dropdown for a specific product in the order, we will call the update fetch method inside the handleStatusChange method, as shown in the following code.

mern-marketplace/client/order/ProductOrderEdit.js:

update({          shopId: props.shopId        }, {          t: jwt.token        }, {          cartItemId: product._id,          status: event.target.value        })        .then((data) => {          if (data.error) {            setValues({              ...values, error: "Status not updated, try again" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Full-Stack React Projects

Full-Stack React Projects

Shama Hoque
React Native - The Practical Guide

React Native - The Practical Guide

Academind by Maximilian Schwarzmüller GmbH

Publisher Resources

ISBN: 9781839215414Supplemental Content