From 46f5097742fdeddfc72eb79fe7b72f1dc71203c7 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Mon, 9 Feb 2026 02:27:58 +0530 Subject: [PATCH] feat: implement dedicated notification pages for agent and user roles. --- src/app/(agent)/agent/notifications/page.tsx | 261 +++++++++++++++++++ src/app/(user)/user/notifications/page.tsx | 251 ++++++++++++++++++ src/components/layout/CommonHeader.tsx | 7 +- 3 files changed, 518 insertions(+), 1 deletion(-) create mode 100644 src/app/(agent)/agent/notifications/page.tsx create mode 100644 src/app/(user)/user/notifications/page.tsx diff --git a/src/app/(agent)/agent/notifications/page.tsx b/src/app/(agent)/agent/notifications/page.tsx new file mode 100644 index 0000000..30ec3ae --- /dev/null +++ b/src/app/(agent)/agent/notifications/page.tsx @@ -0,0 +1,261 @@ +'use client'; + +import { useState } from 'react'; +import Image from 'next/image'; +import Link from 'next/link'; + +// Mock notification data - replace with actual API call when backend is ready +interface Notification { + id: string; + type: 'connection' | 'message' | 'system' | 'update' | 'request'; + title: string; + description: string; + timestamp: string; + read: boolean; + actionUrl?: string; + avatar?: string; +} + +const mockNotifications: Notification[] = [ + { + id: '1', + type: 'request', + title: 'New Connection Request', + description: 'Jane Doe wants to connect with you', + timestamp: '1 hour ago', + read: false, + actionUrl: '/agent/requests', + }, + { + id: '2', + type: 'message', + title: 'New Message', + description: 'You have a new message from Mike Wilson', + timestamp: '3 hours ago', + read: false, + actionUrl: '/agent/message', + }, + { + id: '3', + type: 'connection', + title: 'Connection Accepted', + description: 'Your connection with Sarah Johnson has been confirmed', + timestamp: '1 day ago', + read: true, + actionUrl: '/agent/connections', + }, + { + id: '4', + type: 'system', + title: 'Profile Verification', + description: 'Your profile has been verified successfully', + timestamp: '2 days ago', + read: true, + }, + { + id: '5', + type: 'update', + title: 'New Features Available', + description: 'Check out the latest updates to your dashboard', + timestamp: '5 days ago', + read: true, + }, +]; + +function getNotificationIcon(type: Notification['type']) { + switch (type) { + case 'connection': + return '/assets/icons/user-placeholder-icon.svg'; + case 'message': + return '/assets/icons/message-icon.svg'; + case 'system': + return '/assets/icons/settings-icon.svg'; + case 'update': + return '/assets/icons/notification-bell-icon.svg'; + case 'request': + return '/assets/icons/clipboard-icon.svg'; + default: + return '/assets/icons/notification-bell-icon.svg'; + } +} + +export default function AgentNotificationsPage() { + const [notifications, setNotifications] = useState(mockNotifications); + const [filter, setFilter] = useState<'all' | 'unread'>('all'); + + const filteredNotifications = filter === 'all' + ? notifications + : notifications.filter(n => !n.read); + + const unreadCount = notifications.filter(n => !n.read).length; + + const markAsRead = (id: string) => { + setNotifications(prev => + prev.map(n => n.id === id ? { ...n, read: true } : n) + ); + }; + + const markAllAsRead = () => { + setNotifications(prev => prev.map(n => ({ ...n, read: true }))); + }; + + return ( +
+ {/* Header */} +
+
+
+
+ Notifications +
+
+

+ Notifications +

+

+ {unreadCount > 0 ? `You have ${unreadCount} unread notification${unreadCount > 1 ? 's' : ''}` : 'All caught up!'} +

+
+
+ + {unreadCount > 0 && ( + + )} +
+ + {/* Filter Tabs */} +
+ + +
+
+ + {/* Notifications List */} +
+ {filteredNotifications.length === 0 ? ( +
+
+ No notifications +
+

+ {filter === 'unread' ? 'No unread notifications' : 'No notifications yet'} +

+
+ ) : ( +
+ {filteredNotifications.map((notification) => ( +
+
+ {/* Icon */} +
+ {notification.type} +
+ + {/* Content */} +
+
+
+

+ {notification.title} +

+

+ {notification.description} +

+
+ + {notification.timestamp} + +
+ + {/* Actions */} +
+ {notification.actionUrl && ( + + View details + + )} + {!notification.read && ( + + )} +
+
+ + {/* Unread indicator */} + {!notification.read && ( +
+ )} +
+
+ ))} +
+ )} +
+ + {/* Settings Link */} +
+ + Manage notification settings + +
+
+ ); +} diff --git a/src/app/(user)/user/notifications/page.tsx b/src/app/(user)/user/notifications/page.tsx new file mode 100644 index 0000000..4e550b0 --- /dev/null +++ b/src/app/(user)/user/notifications/page.tsx @@ -0,0 +1,251 @@ +'use client'; + +import { useState } from 'react'; +import Image from 'next/image'; +import Link from 'next/link'; + +// Mock notification data - replace with actual API call when backend is ready +interface Notification { + id: string; + type: 'connection' | 'message' | 'system' | 'update'; + title: string; + description: string; + timestamp: string; + read: boolean; + actionUrl?: string; + avatar?: string; +} + +const mockNotifications: Notification[] = [ + { + id: '1', + type: 'connection', + title: 'New Connection Request', + description: 'John Smith wants to connect with you', + timestamp: '2 hours ago', + read: false, + actionUrl: '/user/connections', + }, + { + id: '2', + type: 'message', + title: 'New Message', + description: 'You have a new message from Sarah Johnson', + timestamp: '5 hours ago', + read: false, + actionUrl: '/user/message', + }, + { + id: '3', + type: 'system', + title: 'Profile Update Reminder', + description: 'Complete your profile to get better recommendations', + timestamp: '1 day ago', + read: true, + actionUrl: '/user/settings', + }, + { + id: '4', + type: 'update', + title: 'New Features Available', + description: 'Check out the latest updates to our platform', + timestamp: '3 days ago', + read: true, + }, +]; + +function getNotificationIcon(type: Notification['type']) { + switch (type) { + case 'connection': + return '/assets/icons/user-placeholder-icon.svg'; + case 'message': + return '/assets/icons/message-icon.svg'; + case 'system': + return '/assets/icons/settings-icon.svg'; + case 'update': + return '/assets/icons/notification-bell-icon.svg'; + default: + return '/assets/icons/notification-bell-icon.svg'; + } +} + +export default function UserNotificationsPage() { + const [notifications, setNotifications] = useState(mockNotifications); + const [filter, setFilter] = useState<'all' | 'unread'>('all'); + + const filteredNotifications = filter === 'all' + ? notifications + : notifications.filter(n => !n.read); + + const unreadCount = notifications.filter(n => !n.read).length; + + const markAsRead = (id: string) => { + setNotifications(prev => + prev.map(n => n.id === id ? { ...n, read: true } : n) + ); + }; + + const markAllAsRead = () => { + setNotifications(prev => prev.map(n => ({ ...n, read: true }))); + }; + + return ( +
+ {/* Header */} +
+
+
+
+ Notifications +
+
+

+ Notifications +

+

+ {unreadCount > 0 ? `You have ${unreadCount} unread notification${unreadCount > 1 ? 's' : ''}` : 'All caught up!'} +

+
+
+ + {unreadCount > 0 && ( + + )} +
+ + {/* Filter Tabs */} +
+ + +
+
+ + {/* Notifications List */} +
+ {filteredNotifications.length === 0 ? ( +
+
+ No notifications +
+

+ {filter === 'unread' ? 'No unread notifications' : 'No notifications yet'} +

+
+ ) : ( +
+ {filteredNotifications.map((notification) => ( +
+
+ {/* Icon */} +
+ {notification.type} +
+ + {/* Content */} +
+
+
+

+ {notification.title} +

+

+ {notification.description} +

+
+ + {notification.timestamp} + +
+ + {/* Actions */} +
+ {notification.actionUrl && ( + + View details + + )} + {!notification.read && ( + + )} +
+
+ + {/* Unread indicator */} + {!notification.read && ( +
+ )} +
+
+ ))} +
+ )} +
+ + {/* Settings Link */} +
+ + Manage notification settings + +
+
+ ); +} diff --git a/src/components/layout/CommonHeader.tsx b/src/components/layout/CommonHeader.tsx index 3362f79..ed50981 100644 --- a/src/components/layout/CommonHeader.tsx +++ b/src/components/layout/CommonHeader.tsx @@ -3,6 +3,7 @@ import { useState, useEffect, useRef, useCallback } from 'react'; import Link from 'next/link'; import Image from 'next/image'; +import { useRouter } from 'next/navigation'; import { useSession, signOut } from 'next-auth/react'; import { agentsService } from '@/services/agents.service'; import { usersService } from '@/services/users.service'; @@ -16,6 +17,7 @@ const navLinks = [ export function CommonHeader() { const { data: session } = useSession(); + const router = useRouter(); const [showProfileMenu, setShowProfileMenu] = useState(false); const profileMenuRef = useRef(null); const [profileImage, setProfileImage] = useState(null); @@ -134,7 +136,10 @@ export function CommonHeader() { {session ? ( <> {/* Notification Bell */} -