Frontend School

Notification Center UI with Read/Unread Functionality

Machine Coding
easy

Notification Center UI with Read/Unread Functionality

Easy
Frontend
React
UI
Notifications
State Management

Overview

Notification centers are crucial for engaging users by keeping them informed about important updates, messages, and activities within an application. For Gupshup, a platform focused on communication, a robust and intuitive notification system is paramount to user experience. In this problem, you will build a core component of such a system, focusing on displaying notifications and managing their read/unread states.

What you need to do / Task

Your goal is to implement a client-side Notification Center component that displays a list of notifications and allows users to manage their read/unread status.

  1. Display Notifications: Render a list of notifications, each showing its message and timestamp.
  2. Mark as Read: Implement functionality to mark an individual notification as read. This should update its status and visual representation.
  3. Mark All as Read: Provide a button or action to mark all currently displayed notifications as read.
  4. Filter Notifications: Allow users to filter the list to show "All" notifications or only "Unread" notifications.
  5. Unread Count: Display the current count of unread notifications prominently.

UI/UX expectations

  • The Notification Center should have a clear title (e.g., "Notifications").
  • Each notification item should clearly display its message and timestamp.
  • Unread notifications should be visually distinct from read ones (e.g., different background color, bold text).
  • Each notification should have an interactive element (e.g., a button or click area) to mark it as read. This action should only be available for unread notifications.
  • A "Mark All as Read" button should be present, ideally at the top of the list.
  • Filter controls (e.g., toggle buttons) for "All" and "Unread" notifications should be available.
  • The unread count should be visible and update dynamically.

Acceptance criteria

  • Notifications are rendered correctly based on the provided mock data.
  • Clicking an individual notification's "Mark as Read" action changes its state to read and updates its visual style.
  • The "Mark All as Read" button correctly sets all notifications to read state.
  • The filter mechanism correctly displays only unread notifications when "Unread" is selected, and all notifications when "All" is selected.
  • The unread count accurately reflects the number of unread notifications and updates dynamically with state changes.
  • The UI is responsive to user interactions without noticeable lag.

Constraints

Constraints & assumptions

  • You will be working with a static mock dataset of notifications.
  • All state management should be client-side (e.g., using React's useState).
  • No backend integration, API calls, or persistent storage is required.
  • Focus on React (with TypeScript) for building the UI and managing component state.
  • The notification list size will be small (e.g., 5-10 items).
  • Basic styling is sufficient; pixel-perfect design is not the primary focus, but readability and usability are.

Out of scope

  • Real-time updates (e.g., WebSockets).
  • Pagination or infinite scrolling for notifications.
  • Advanced filtering or sorting capabilities (e.g., by type, date range).
  • User authentication or personalization.
  • Accessibility beyond basic interactive elements.

What interviewers evaluate

  • Code Structure and Readability: Clarity, organization, and maintainability of the React components and logic.
  • State Management: Effective use of React hooks (useState, useMemo, useCallback) to manage component state and re-renders.
  • Functional Correctness: All features outlined in the "What you need to do / Task" section are implemented and work as expected.
  • UI/UX Implementation: Adherence to the specified UI/UX expectations, including visual feedback for different states.

Loading editor...