Frontend School

Razorpay Notification Center: Grouping, Filtering, and Actions

Machine Coding
hard

Razorpay Notification Center: Grouping, Filtering, and Actions

Hard
Frontend
React
State Management
Notifications
UI/UX

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.

  1. 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).
  2. 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.
  3. 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.
  4. 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.

Constraints

Constraints & assumptions

  • You should use React for this implementation.
  • The application should be a Single Page Application (SPA).
  • Assume all notification data is initially available client-side (mock data provided). No API calls are required.
  • The maximum number of notifications is expected to be around 100-200.
  • Focus on functional correctness, clean code, and good React practices (component composition, state management).
  • No external state management libraries (e.g., Redux, Zustand) are required; useState and useReducer are sufficient.

Out of scope

  • Backend integration or API calls.
  • Complex animations or transitions beyond basic CSS.
  • Internationalization (i18n).
  • Persistent storage (notifications do not need to persist across page reloads).
  • Advanced accessibility features beyond basic semantic HTML and clear labels.

What interviewers evaluate

  • Architectural Design: How well the component structure and state management are organized for maintainability and scalability.
  • React Proficiency: Effective use of React hooks, lifecycle, and component composition.
  • Problem Solving: Ability to tackle complex grouping, sorting, filtering, and state update logic efficiently.
  • Code Quality: Readability, conciseness, error handling, and adherence to best practices.

Loading editor...