diff --git a/frontend/src/AgroShopAI/components/Pages/Trending.jsx b/frontend/src/AgroShopAI/components/Pages/Trending.jsx new file mode 100644 index 00000000..a3b34f2a --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/Trending.jsx @@ -0,0 +1,120 @@ +import React, { useState } from "react"; +import Header from "./components/THeader"; +import Banner from "./components/Banner"; +import SearchAndSort from "./components/SearchAndSort"; +import ProductGrid from "./components/ProductGrid"; + +export default function TrendingProductsPage() { + const [sortBy, setSortBy] = useState("trending"); + const [searchTerm, setSearchTerm] = useState(""); + const [isLoading, setIsLoading] = useState(false); + + // Filtering products based on search term + const filteredProducts = trendingProducts.filter((product) => + product.name.toLowerCase().includes(searchTerm.toLowerCase()) + ); + + // Sorting products based on selected criteria + const sortedProducts = [...filteredProducts].sort((a, b) => { + if (sortBy === "price") return a.price - b.price; + if (sortBy === "rating") return b.rating - a.rating; + return 0; + }); + + // Simulate loading state + const fetchData = async () => { + setIsLoading(true); + setTimeout(() => { + setIsLoading(false); + }, 2000); + }; + + React.useEffect(() => { + fetchData(); + }, []); + + return ( +
+
+ +
+ {/* Search and Sort Component */} + + {/* Loading state and Product Grid */} + {isLoading ? ( +
+ Loading... +
+ ) : ( + + )} +
+
+ ); +} + +const trendingProducts = [ + { + id: 1, + name: "Smart Irrigation System", + price: 299.99, + rating: 4.8, + reviews: 120, + image: + "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTTkXzsfqi9x6H46rC1Ir7k2WEQ1V0lVv8ONA&s", + tag: "Trending Now", + }, + { + id: 2, + name: "Organic Fertilizer Pack", + price: 49.99, + rating: 4.5, + reviews: 85, + image: "https://m.media-amazon.com/images/I/91Y3l-BVm-L.jpg", + tag: "Hot Deal", + }, + { + id: 3, + name: "Drone Crop Sprayer", + price: 1299.99, + rating: 4.9, + reviews: 200, + image: + "https://5.imimg.com/data5/ANDROID/Default/2022/4/AA/WY/ED/14166347/product-jpeg-500x500.jpg", + tag: "Top Rated", + }, + { + id: 4, + name: "Soil pH Tester", + price: 29.99, + rating: 4.2, + reviews: 60, + image: "https://m.media-amazon.com/images/I/71933Pfn55L.jpg", + tag: "Trending Now", + }, + { + id: 5, + name: "Hydroponic Growing Kit", + price: 199.99, + rating: 4.7, + reviews: 150, + image: + "https://m.media-amazon.com/images/I/81n3GQOCOQL._AC_UF1000,1000_QL80_.jpg", + tag: "Hot Deal", + }, + { + id: 6, + name: "Weather Station", + price: 149.99, + rating: 4.6, + reviews: 95, + image: + "https://5.imimg.com/data5/YN/KT/YB/SELLER-5098190/weather-station.jpg", + tag: "Top Rated", + }, +]; diff --git a/frontend/src/AgroShopAI/components/Pages/components/Banner.jsx b/frontend/src/AgroShopAI/components/Pages/components/Banner.jsx new file mode 100644 index 00000000..8c1d21e1 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/components/Banner.jsx @@ -0,0 +1,37 @@ +export default function Banner() { + return ( +
+
+ {/* Heading */} +

+ Trending in AgroTech +

+ + {/* Description */} +

+ Discover the latest and most popular agricultural innovations! Stay + ahead with new technologies. +

+ + {/* Call to Action */} +
+ + +
+ + {/* Image Section (Optional for added visual appeal) */} +
+ Agriculture Innovations +
+
+
+ ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/components/ProductGrid.jsx b/frontend/src/AgroShopAI/components/Pages/components/ProductGrid.jsx new file mode 100644 index 00000000..32abf146 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/components/ProductGrid.jsx @@ -0,0 +1,12 @@ + +import ProductCard from "./TProductCard"; + +export default function ProductGrid({ sortedProducts }) { + return ( +
+ {sortedProducts.map((product) => ( + + ))} +
+ ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/components/SearchAndSort.jsx b/frontend/src/AgroShopAI/components/Pages/components/SearchAndSort.jsx new file mode 100644 index 00000000..7daa7f2f --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/components/SearchAndSort.jsx @@ -0,0 +1,63 @@ +import { Search, ChevronDown } from "lucide-react"; + +export default function SearchAndSort({ + searchTerm, + setSearchTerm, + sortBy, + setSortBy, +}) { + return ( +
+ {/* Search Input */} +
+ + setSearchTerm(e.target.value)} + aria-label="Search products" + /> + +
+ + {/* Sort By Dropdown */} +
+ + + +
+ + {/* Filter Button */} +
+ +
+
+ ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/components/THeader.jsx b/frontend/src/AgroShopAI/components/Pages/components/THeader.jsx new file mode 100644 index 00000000..1e34520c --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/components/THeader.jsx @@ -0,0 +1,32 @@ +export default function Header() { + return ( +
+
+ {/* Logo and Title */} +
+ AgroShop Logo +

AgroShop

+
+ + {/* Navigation Links */} + + + {/* Mobile Menu Button */} +
+ +
+
+
+ ) +} diff --git a/frontend/src/AgroShopAI/components/Pages/components/TProductCard.jsx b/frontend/src/AgroShopAI/components/Pages/components/TProductCard.jsx new file mode 100644 index 00000000..c9d405a3 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/components/TProductCard.jsx @@ -0,0 +1,59 @@ +import { Star } from "lucide-react"; + +export default function ProductCard({ product }) { + return ( +
+ {/* Product Image and Tag */} +
+ {product.name} + + {product.tag} + +
+ + {/* Product Details */} +
+
+

+ {product.name} +

+ + {product.stock} in stock + +
+ + {/* Rating and Reviews */} +
+ + + {product.rating} + + + ({product.reviews} reviews) + +
+ + {/* Price */} +

+ ${product.price.toFixed(2)} +

+ + {/* Add to Cart Button */} + +
+ + {/* Hover Effect */} +
+ + Free shipping on orders over $50! + +
+
+ ); +} diff --git a/frontend/src/MainContent.jsx b/frontend/src/MainContent.jsx index 18cccf7c..e7646a52 100644 --- a/frontend/src/MainContent.jsx +++ b/frontend/src/MainContent.jsx @@ -93,10 +93,14 @@ import FlashSale from './AgroShopAI/components/Pages/components/SalePage'; import WaterManagement from './components/models/WaterManagement'; + +import TrendingProductsPage from './AgroShopAI/components/Pages/Trending'; + import AffiliateProgramPage from './AgroShopAI/components/Pages/Affiliate'; + const MainContent = () => { UseScrollToTop(); const location = useLocation(); // Get the current route @@ -211,7 +215,7 @@ const MainContent = () => { } /> } /> } /> - + } /> {checkShop ? :