Overview
Razorpay's merchant dashboard relies on a robust Notification Center to keep users informed about critical events like payment successes, failures, disputes, and system alerts. A well-designed notification system is crucial for merchants to act promptly and manage their business effectively. This problem challenges you to build a core part of this Notification Center, focusing on efficient display, state management, and user interaction.
What you need to do / Task
Your primary task is to implement a React component for a Notification Center that displays, manages, and allows interaction with a list of notifications.
-
Display Notifications:
- Render a list of notifications. Each notification should display its
message, category, and timestamp.
- Grouped Display: Notifications must be visually grouped by their
category. Within each category group, notifications should be sorted in descending order of timestamp (newest first).
- Visually distinguish between "read" and "unread" notifications. Unread notifications should be more prominent (e.g., bold text, different background).
-
Notification Actions:
- Mark as Read/Unread: Each notification item should have an action (e.g., a button or click handler) to toggle its read/unread status.
- Dismiss: Each notification item should have an action (e.g., a close button) to dismiss it. Dismissed notifications should be removed from the display.
- "Mark All as Read": Implement a global button (e.g., at the top of the Notification Center) that marks all currently visible notifications as read.
-
Filtering/Tabs:
- Implement two tabs: "All Notifications" and "Unread Only".
- "All Notifications" tab should display all non-dismissed notifications, grouped and sorted as specified above.
- "Unread Only" tab should display only unread, non-dismissed notifications, grouped and sorted.
-
Simulate New Notifications:
- Add a button "Add New Notification" that, when clicked, generates and adds a new, unread notification to the list. This new notification should integrate correctly into the existing grouping, sorting, and filtering logic.
UI/UX expectations
- The Notification Center should have a clear header, tabs for filtering, and the "Mark All as Read" button.
- Notifications should be grouped with a visible category header.
- Each notification item should clearly show its message, category, timestamp, and actions (toggle read/unread, dismiss).
- Visual feedback for state changes (e.g., an unread notification becoming read).
- Use basic styling to make the component presentable and functional. Accessibility considerations (e.g., button labels) are a plus.
Acceptance criteria
- Notifications are correctly grouped by category and sorted by timestamp (newest first) within groups.
- Read and unread notifications are visually distinct.
- Clicking a notification's action toggles its read/unread status correctly.
- Dismissing a notification removes it from the display.
- "Mark All as Read" button correctly updates the status of all visible notifications.
- Filtering tabs ("All", "Unread Only") display the correct subset of notifications.
- Adding a new notification correctly appears in the appropriate group and tab.
- The component handles state immutability correctly; no direct state mutations.