-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basket product #28
base: main
Are you sure you want to change the base?
Basket product #28
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few unnecessary lines to delete, as commented below, and that's the price for each item in the basket sorted 👍
Do you want to have a go at putting the sub-totals, or final total, following the Figma sketch of what the basket page should look like?
{ product_id: 1, quantity: 2, price: 5 }, | ||
{ product_id: 3, quantity: 1, price: 3 }, | ||
{ product_id: 4, quantity: 1, price: 9 }, | ||
{ product_id: 5, quantity: 3, price: 7 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need these lines - the price for each product is queried from the database. (See further comments below.)
]; | ||
let itemIds = []; | ||
let quantity = []; | ||
let price = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you don't need this line either. (No need to set up the array.)
|
||
basketArray.map((items) => { | ||
itemIds.push(items.product_id); | ||
quantity.push(items.quantity); | ||
price.push(items.price); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you don't need this line either. (No need to push the prices to the array :)
@@ -55,7 +57,8 @@ export default function Basket({ products }) { | |||
{products.map((product, index) => ( | |||
<div key={product.id}> | |||
<h2>{product.name}</h2> | |||
<p>quantity: {quantity[index]}</p> | |||
<p>quantity:{quantity[index]}</p> | |||
<p>price:{product.price}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is correct, so it can stay as it is.
(The "product" object here has come from the database, and its property "price" is the price we want to display.)
No description provided.