Frontend School

Swiggy Menu Item Editor Grid

Machine Coding
medium

Swiggy Menu Item Editor Grid

Medium
React
Frontend
UI
Data Grid
Editable Table
State Management

Overview

At Swiggy, empowering our restaurant partners with efficient tools to manage their offerings is paramount. One such critical tool is the menu management system. This problem focuses on building a core component of that system: an editable data grid for menu items. This component allows restaurant staff to quickly view, update, add, and remove menu items, directly impacting the accuracy of what customers see and the operational efficiency of our partners.

What you need to do / Task

Your task is to build a React component that displays a list of menu items in a tabular format and allows for in-place editing, addition, and deletion of these items.

  1. Render Menu Items: Display the provided mock menuItems data in a grid/table structure.
  2. In-place Editing: Enable editing for the price and category fields directly within the grid. When a cell is clicked/focused, it should transform into an input field. Changes should be saved upon pressing Enter or blurring the input.
  3. Toggle Availability: The available field should be represented by a toggle switch or checkbox. Clicking it should immediately update the item's availability status.
  4. Add New Item: Implement a button (e.g., "Add New Item") that, when clicked, appends a new, empty, and editable row to the grid. The new item should have a unique ID.
  5. Delete Item: Each row should have a "Delete" action (e.g., a button or icon) that, when clicked, removes the corresponding menu item from the grid.
  6. State Management: All modifications (edits, additions, deletions) should be managed in the component's local state and instantly reflected in the UI.

UI/UX expectations

  • Layout: Display menu items in a clear table format with columns for ID, Name, Price, Category, Available, and Actions.
  • Editable Fields: Price and Category cells should visually indicate their editable nature (e.g., on hover, or an input field appears on click/focus). The available field should be a simple toggle (checkbox or switch).
  • Actions: A distinct button or icon for deleting a row, and a prominent "Add New Item" button below the grid.
  • User Feedback: Changes should be immediately visible. For price/category, the input should revert to plain text after editing is saved.
  • Basic Styling: Minimal styling to ensure readability and usability (e.g., borders for cells, clear button styles).

Acceptance criteria

  • The grid renders correctly with the initial mock data.
  • Clicking a price cell makes it editable, and changes are saved to state on Enter or blur.
  • Clicking a category cell makes it editable, and changes are saved to state on Enter or blur.
  • Clicking the available toggle/checkbox instantly updates the item's availability status in the UI and state.
  • The "Add New Item" button successfully adds a new, uniquely identifiable, empty, and editable row to the bottom of the grid.
  • The "Delete" action on any row successfully removes that item from the grid and state.
  • All state changes are reflected in the UI without manual refresh.

Constraints

Constraints & assumptions

  • You must use React (functional components and hooks).
  • Data persistence is not required; all changes should be managed in the component's local state (in-memory).
  • Focus on core functionality; extensive styling is not a priority beyond basic usability.
  • Assume input for price will be a valid number (no complex number validation needed).
  • The grid will contain a small number of rows (e.g., up to 10-15 items).
  • No external libraries are required beyond React itself.

Out of scope

  • Backend API integration or data fetching.
  • Advanced input validation (e.g., min/max price, specific category formats).
  • Pagination, sorting, or filtering functionality for the grid.
  • Complex accessibility features beyond standard semantic HTML elements.
  • Responsive design for different screen sizes.

What interviewers evaluate

  • Correctness & Completeness: Accurate implementation of all specified editing, adding, and deleting functionalities.
  • React Principles: Effective use of React state management, component composition, and event handling.
  • Code Structure: Clean, readable, and maintainable code with logical separation of concerns.
  • UI/UX Adherence: Ability to translate requirements into a functional and user-friendly interface.

Loading editor...