From b307bfa19e2e69a67efe54d8cfc5bd2632763524 Mon Sep 17 00:00:00 2001 From: Ikki Date: Sat, 9 Nov 2024 14:50:30 +0530 Subject: [PATCH] product-carousel-seller --- .../Pages/components/ProductCarousel.jsx | 83 +++++++++++++++++++ .../SellerProductManagementPage.jsx | 3 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 frontend/src/AgroShopAI/components/Pages/components/ProductCarousel.jsx diff --git a/frontend/src/AgroShopAI/components/Pages/components/ProductCarousel.jsx b/frontend/src/AgroShopAI/components/Pages/components/ProductCarousel.jsx new file mode 100644 index 00000000..0ab355fc --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/components/ProductCarousel.jsx @@ -0,0 +1,83 @@ +import React, { useState, useEffect } from 'react' + +export default function FeaturedProductsCarousel() { + const [currentIndex, setCurrentIndex] = useState(0) + + useEffect(() => { + const timer = setInterval(() => { + setCurrentIndex((prevIndex) => (prevIndex + 1) % dummyProducts.length) + }, 5000) + + return () => clearInterval(timer) + }, []) + + const nextSlide = () => { + setCurrentIndex((prevIndex) => (prevIndex + 1) % dummyProducts.length) + } + + const prevSlide = () => { + setCurrentIndex((prevIndex) => (prevIndex - 1 + dummyProducts.length) % dummyProducts.length) + } + + return ( +
+

Featured Products

+
+
+ {[...dummyProducts, ...dummyProducts.slice(0, 2)].map((product, index) => ( +
+
+
+

{product.name}

+

{product.description}

+

${product.price.toFixed(2)}

+
+
+
+ ))} +
+ + +
+
+ {dummyProducts.map((_, index) => ( +
+
+ ) +} + +const dummyProducts = [ + { id: 1, name: 'Organic Fertilizer', price: 19.99, description: 'Nutrient-rich organic fertilizer for all crops', backgroundImage: 'https://i0.wp.com/www.bigtoolbox.com/wp-content/uploads/2022/05/BTB-Blog-Organic.jpg' }, + { id: 2, name: 'Drip Irrigation Kit', price: 89.99, description: 'Water-saving irrigation system for efficient farming', backgroundImage: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQdCiwqx3GQ4LZS_qTaGO-5yWa_Scrkv2gjiI3IYVHzV79t0ERXbM7NH0FBBexMYJBeZ9Y&usqp=CAU' }, + { id: 3, name: 'Heirloom Tomato Seeds', price: 4.99, description: 'Non-GMO, organic heirloom tomato seed variety pack', backgroundImage: 'https://www.threshseed.com/cdn/shop/files/mule-team-heirloom-tomato-seeds-43401418637561.jpg?v=1726787052&width=2000' }, + { id: 4, name: 'Pruning Shears', price: 24.99, description: 'High-quality steel pruning shears for precise cuts', backgroundImage: 'https://www.hausandgarten.com/cdn/shop/articles/Hero_Image_-_How_To_Use_Pruning_Shears_600x.png?v=1706594768' }, + { id: 5, name: 'Soil pH Tester', price: 29.99, description: 'Digital soil pH meter for optimal crop management', backgroundImage: 'https://thehomesteadingrd.com/wp-content/uploads/2022/06/The-5-Best-Soil-pH-Testers-in-2022-cover-e1700235887801.jpg' }, + { id: 6, name: 'Composting Bin', price: 49.99, description: 'Large-capacity composting bin for organic waste', backgroundImage: 'https://4344835.fs1.hubspotusercontent-na1.net/hubfs/4344835/Imported_Blog_Media/setting-up-outdoor-compost-bin_a-1.jpg' }, +] diff --git a/frontend/src/AgroShopAI/components/Pages/components/SellerProductManagementPage.jsx b/frontend/src/AgroShopAI/components/Pages/components/SellerProductManagementPage.jsx index 9cb7e05e..3f5faaff 100644 --- a/frontend/src/AgroShopAI/components/Pages/components/SellerProductManagementPage.jsx +++ b/frontend/src/AgroShopAI/components/Pages/components/SellerProductManagementPage.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; - +import FeaturedProductsCarousel from './ProductCarousel' const SellerProductManagementPage = ({ products, searchTerm, @@ -68,6 +68,7 @@ const SellerProductManagementPage = ({ ))} + ); }