-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.jsx
60 lines (55 loc) · 2.37 KB
/
test.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { useState, useEffect } from 'react';
import { Carousel } from 'primereact/carousel';
import { Button } from 'primereact/button';
import { ProductService } from '../service/ProductService';
import './CarouselDemo.css';
const CarouselDemo = () => {
const [products, setProducts] = useState([]);
const responsiveOptions = [
{
breakpoint: '1024px',
numVisible: 3,
numScroll: 3
},
{
breakpoint: '600px',
numVisible: 2,
numScroll: 2
},
{
breakpoint: '480px',
numVisible: 1,
numScroll: 1
}
];
const productService = new ProductService();
useEffect(() => {
productService.getProductsSmall().then(data => setProducts(data.slice(0,9)));
}, []); // eslint-disable-line react-hooks/exhaustive-deps
const productTemplate = (product) => {
return (
<div className="product-item">
<div className="product-item-content">
<div className="mb-3">
<img src={images/product/${product.image}} onError={(e) => e.target.src='https://www.primefaces.org/wp-content/uploads/2020/05/placeholder.png'} alt={product.name} className="product-image" />
</div>
<div>
<h4 className="mb-1">{product.name}</h4>
<h6 className="mt-0 mb-3">${product.price}</h6>
<span className={product-badge status-${product.inventoryStatus.toLowerCase()}}>{product.inventoryStatus}</span>
<div className="car-buttons mt-5">
<Button icon="pi pi-search" className="p-button p-button-rounded mr-2" />
<Button icon="pi pi-star-fill" className="p-button-success p-button-rounded mr-2" />
<Button icon="pi pi-cog" className="p-button-help p-button-rounded" />
</div>
</div>
</div>
</div>
);
}
return (
<div className="carousel-demo">
<div className="card">
<Carousel value={products} numVisible={3} numScroll={3} responsiveOptions={responsiveOptions}
itemTemplate={productTemplate} header={<h5>Basic</h5>} />
</div>