From 08f4a6db9b0c8c690b874e20fa317cd4371f5e80 Mon Sep 17 00:00:00 2001 From: Ikki Date: Sun, 10 Nov 2024 18:37:34 +0530 Subject: [PATCH] notification_page --- .../Pages/FeaturedProductsSection.jsx | 27 +++ .../components/Pages/HeroSection.jsx | 13 ++ .../components/Pages/NotficationHeader.jsx | 35 +++ .../components/Pages/NotificationPage.jsx | 205 ++++++++++++++++++ frontend/src/MainContent.jsx | 4 +- 5 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 frontend/src/AgroShopAI/components/Pages/FeaturedProductsSection.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/HeroSection.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/NotficationHeader.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/NotificationPage.jsx diff --git a/frontend/src/AgroShopAI/components/Pages/FeaturedProductsSection.jsx b/frontend/src/AgroShopAI/components/Pages/FeaturedProductsSection.jsx new file mode 100644 index 00000000..1e829a7a --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/FeaturedProductsSection.jsx @@ -0,0 +1,27 @@ +import React from 'react' + +export default function FeaturedProductsSection() { + return ( +
+
+

Featured Products

+
+ {featuredProducts.map(product => ( +
+ {product.name} +

{product.name}

+

{product.price}

+ +
+ ))} +
+
+
+ ) +} diff --git a/frontend/src/AgroShopAI/components/Pages/HeroSection.jsx b/frontend/src/AgroShopAI/components/Pages/HeroSection.jsx new file mode 100644 index 00000000..c50845e5 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/HeroSection.jsx @@ -0,0 +1,13 @@ +import React from 'react' + +export default function HeroSection() { + return ( +
+
+

Welcome to Agroshop

+

Your one-stop shop for all agricultural needs

+ Shop Now +
+
+ ) +} diff --git a/frontend/src/AgroShopAI/components/Pages/NotficationHeader.jsx b/frontend/src/AgroShopAI/components/Pages/NotficationHeader.jsx new file mode 100644 index 00000000..e95aec96 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/NotficationHeader.jsx @@ -0,0 +1,35 @@ +import React from "react"; + +export default function Header() { + return ( +
+
+

Agroshop

+ +
+
+ ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/NotificationPage.jsx b/frontend/src/AgroShopAI/components/Pages/NotificationPage.jsx new file mode 100644 index 00000000..32d423e5 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/NotificationPage.jsx @@ -0,0 +1,205 @@ +import React, { useState } from 'react' + + +const initialNotices = [ + { id: 1, title: 'New Organic Fertilizers', content: 'Check out our latest range of organic fertilizers, now available!', date: '2024-03-10', active: true }, + { id: 2, title: 'Seasonal Seed Sale', content: 'Get 20% off on all vegetable seeds this week.', date: '2024-03-08', active: true }, + { id: 3, title: 'Farming Workshop', content: 'Join our expert-led workshop on sustainable farming practices this Saturday.', date: '2024-03-05', active: false }, + { id: 4, title: 'New Irrigation Systems', content: 'Explore our new range of water-efficient irrigation systems.', date: '2024-03-03', active: true }, + { id: 5, title: 'Pest Control Webinar', content: 'Register for our upcoming webinar on organic pest control methods.', date: '2024-03-01', active: true }, +] + +// Dummy data for featured products +const featuredProducts = [ + { id: 1, name: 'Organic Tomato Seeds', price: '$4.99', image: '/placeholder.svg?height=100&width=100' }, + { id: 2, name: 'Premium Soil Mix', price: '$19.99', image: '/placeholder.svg?height=100&width=100' }, + { id: 3, name: 'Eco-Friendly Pesticide', price: '$24.99', image: '/placeholder.svg?height=100&width=100' }, + { id: 4, name: 'Garden Tool Set', price: '$49.99', image: '/placeholder.svg?height=100&width=100' }, +] + +export default function Notification() { + const [notices, setNotices] = useState(initialNotices) + const [newNotice, setNewNotice] = useState({ title: '', content: '', date: '' }) + const [isAdmin, setIsAdmin] = useState(false) + const [showNotification, setShowNotification] = useState(false) + + const handleInputChange = (e) => { + const { name, value } = e.target + setNewNotice(prev => ({ ...prev, [name]: value })) + } + + const addNotice = () => { + if (newNotice.title && newNotice.content && newNotice.date) { + setNotices(prev => [ + { id: prev.length + 1, ...newNotice, active: true }, + ...prev, + ]) + setNewNotice({ title: '', content: '', date: '' }) + setShowNotification(true) + setTimeout(() => setShowNotification(false), 3000) + } + } + + const toggleNoticeStatus = (id) => { + setNotices(prev => + prev.map(notice => + notice.id === id ? { ...notice, active: !notice.active } : notice + ) + ) + } + + const deleteNotice = (id) => { + setNotices(prev => prev.filter(notice => notice.id !== id)) + } + + return ( +
+
+
+

Agroshop

+ +
+
+ +
+
+

Welcome to Agroshop

+

Your one-stop shop for all agricultural needs

+ Shop Now +
+
+ +
+ + +
+
+

Latest Notices

+ {isAdmin && ( +
+

Add New Notice

+
+ + + + +
+
+ )} +
+ {notices + .filter(notice => isAdmin || notice.active) + .map(notice => ( +
+

{notice.title}

+

Posted on: {notice.date}

+

{notice.content}

+ {isAdmin && ( +
+ + +
+ )} +
+ ))} +
+
+
+

Featured Products

+
+ {featuredProducts.map(product => ( +
+ {product.name} +

{product.name}

+

{product.price}

+ +
+ ))} +
+
+
+
+ +
+
+
+

About Agroshop

+

Your trusted partner in agricultural solutions. We provide high-quality products and expert advice for all your farming needs.

+
+
+

Quick Links

+ +
+
+

Contact Us

+

123 Farm Road, Greenville, AG 12345

+

Phone: (555) 123-4567

+

Email: info@agroshop.com

+
+
+
+ + {showNotification && ( +
+ New notice added successfully! +
+ )} +
+ ) +} \ No newline at end of file diff --git a/frontend/src/MainContent.jsx b/frontend/src/MainContent.jsx index 91fc3611..499d4ae0 100644 --- a/frontend/src/MainContent.jsx +++ b/frontend/src/MainContent.jsx @@ -107,8 +107,7 @@ import RentSupportPage from './AgroRentAI/components/RentSupportPage'; import WarehouseInventory from './AgroShopAI/components/Pages/Admin-Warehouse'; import FarmerSuccessStories from './AgroShopAI/components/Pages/components/SuccessPage'; - - +import Notification from './AgroShopAI/components/Pages/NotificationPage'; @@ -236,6 +235,7 @@ const MainContent = () => { } /> } /> } /> + } /> {checkShop ? :