Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Basket product #28

wants to merge 2 commits into from

Conversation

Bereketmebrahtu
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Jun 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
week6-bereket-hussain-joe-sonia ✅ Ready (Inspect) Visit Preview Jun 16, 2022 at 3:12PM (UTC)

Copy link
Contributor

@joe-dev-public joe-dev-public left a 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?

Comment on lines +20 to +23
{ 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 },
Copy link
Contributor

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 = [];
Copy link
Contributor

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);
Copy link
Contributor

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>
Copy link
Contributor

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants