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

Assignment completed. #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';

import Products from './components/Products';

const products = [
Expand Down Expand Up @@ -87,7 +86,7 @@ const App = () => {
return (
<div>
<h1 className="title">BD Store</h1>
<Products />
<Products products={products} />
</div>
);
};
Expand Down
29 changes: 19 additions & 10 deletions src/components/Product.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
/* eslint-disable react/prop-types */
import React from 'react';

const Product = () => {
const Product = (props) => {
// const id = props.id;
const title = props.title;
const price = props.price;
const description = props.description;
// const category = props.category;
const image = props.image;
const rating = props.rating;
return (
<>
<article className="product">
<img src="" alt="" />
<div className="product__details">
<h4 className="product__title">product title</h4>
<p>Price: $ product price</p>
<p>Rating: product rating rate/5</p>
<p className="product__desc">Description: product.description</p>
<button className="product__btn btn">Add to cart</button>
</div>
</article>
<img src={image} alt="" />
<div className="product__details">
<h4 className="product__title">{title}</h4>
<p>Price: ${price}</p>
<p>Rating:{rating}/5</p>
<p className="product__desc">Description: {description}</p>
<button className="product__btn btn">Add to cart</button>
</div>
</article>
</>
);
};

Expand Down
26 changes: 26 additions & 0 deletions src/components/Products.js
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
/* eslint-disable react/prop-types */
import Product from '../components/Product';

const Products = (props) => {
const products = props.products;
return (
<div className="products">
{products.map((product, index) => {
const { id, title, price, description, category, image, rating } = product;
return (
<Product
key={index}
id={id}
title={title}
price={price}
description={description}
category={category}
image={image}
rating={rating.rate}
/>
);
})}
</div>
);
};

export default Products;