-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProductsList.jsx
38 lines (36 loc) · 1.26 KB
/
ProductsList.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Link, useLoaderData } from 'react-router-dom';
import { formatPrice } from '../utils';
const ProductsList = () => {
const { products } = useLoaderData();
return (
<div className='mt-12 grid gap-y-8'>
{products.map((product) => {
const { title, price, image, company } = product.attributes;
const dollarsAmount = formatPrice(price);
return (
<Link
key={product.id}
to={`/products/${product.id}`}
className='p-8 rounded-lg flex flex-col sm:flex-row gap-y-4 flex-wrap bg-base-100 shadow-xl hover:shadow-2xl duration-300 group'
>
<img
src={image}
alt={title}
className='h-24 w-24 rounded-lg sm:h-32 sm:w-32 object-cover group-hover:scale-105 transition duration-300'
/>
<div className='ml-0 sm:ml-16'>
<h3 className='capitalize font-medium text-lg'>{title}</h3>
<h4 className='capitalize text-md text-neutral-content'>
{company}
</h4>
</div>
<p className='font-medium ml-0 sm:ml-auto text-lg'>
{dollarsAmount}
</p>
</Link>
);
})}
</div>
);
};
export default ProductsList;