Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
Error: Typing on the input field of pick for each row just duplicates whatever value was entered in the qty field

So I have this field where you can enter the quantity for each row. It was working, however, when I added another input field for the pick, it will just duplicate whatever was entered in either of the fields. How do I fix this? Any help would be appreciated.

adding into the cart items:

const handleAdd = (id, name, price, size, cat, color, quan = null, pick) => {
    console.log("add", id, name, price, size, cat, color, quan, pick);
    const productExist = cartItems.find(
      (item) => item.id === id && item.color === color
    );

    if (productExist) {
      setCartItems(
        cartItems.map((item) =>
          item.id === id && item.color === color
            ? {
                ...productExist,
                quantity:
                  quan === "" || quan ? quan : +productExist.quantity + 1
              }
            : item
        )
      );
    } else {
      setCartItems([
        ...cartItems,
        { id, name, price, size, cat, color, quantity: 1, pick }
      ]);
    }
  };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have serval errors in your code.

  1. First, you are not setting values in correct order when calling handleAdd method. That's why you are facing issues you have described in your question.

  2. Second, there is no property in object item called prodName, it should be just name.

Here is working solution.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!