Frontend School

Transaction Ledger Editor

Machine Coding
hard

Transaction Ledger Editor

Hard
React
TypeScript
Data Grid
State Management
UI/UX
Validation

Overview

In financial management applications like QuickBooks, users frequently interact with large datasets of transactions. An intuitive and efficient way to manage these records is through an editable data grid. This problem challenges you to build a simplified version of such a grid, focusing on in-place editing, data validation, and basic row management, crucial for a seamless user experience in data entry and reconciliation workflows.

What you need to do / Task

Your goal is to implement a React component that renders an editable data grid for managing financial transactions.

  1. Render the Grid: Display the provided mock transaction data in a tabular format. Each row should represent a transaction, and columns should correspond to transaction properties (e.g., id, date, description, amount, category).
  2. In-place Cell Editing:
    • Clicking on a non-ID cell should transform it into an editable input field.
    • The input field should be pre-populated with the current cell's value.
    • Pressing Enter or blurring the input field should save the changes and revert the cell to its display state.
    • Pressing Escape should discard changes and revert the cell to its original display state.
  3. Data Validation:
    • The amount column must only accept valid numeric input. If an invalid value is entered, the cell should visually indicate an error state (e.g., red border), and the change should not be saved until fixed.
    • The date column should ideally accept a valid date format (e.g., YYYY-MM-DD). For simplicity, you can treat this as a string input but ensure it's not empty.
  4. Add/Delete Row Functionality:
    • Provide a button to add a new, empty row to the grid. The new row should have a unique id and default values for other fields (e.g., empty strings, 0 for amount).
    • Each row should have a mechanism (e.g., a delete button/icon) to remove itself from the grid.
  5. Total Amount Calculation:
    • Display a running total of all valid amount values at the bottom of the grid. This total should update dynamically as transactions are edited, added, or deleted.

UI/UX expectations

  • The grid should have clear headers for each column.
  • Editable cells should visually indicate their editable state (e.g., an <input> element).
  • Invalid input for the amount field should show a distinct visual error (e.g., a red border on the input field).
  • Buttons for "Add Row" and delete icons/buttons for each row should be clearly visible and functional.
  • The total amount should be clearly displayed and formatted (e.g., currency).
  • Basic styling is expected for readability and functionality; extensive pixel-perfect design is not required.

Acceptance criteria

  • The grid renders correctly with the initial mock data.
  • Clicking a non-ID cell makes it editable.
  • Changes made in an editable cell are saved on blur or Enter key press.
  • Changes are discarded on Escape key press.
  • The amount field correctly validates for numeric input; invalid input prevents saving and shows an error.
  • A new row can be added to the grid with default values and a unique ID.
  • Existing rows can be deleted from the grid.
  • The total amount updates accurately in real-time as transactions are modified, added, or deleted.

Constraints

Constraints & assumptions

  • You must use React and TypeScript.
  • Data manipulation should occur entirely on the client-side; no API calls or backend persistence are required.
  • The initial dataset size will be small (e.g., 5-10 rows). Performance optimizations for very large datasets (e.g., virtualization) are out of scope.
  • Focus on functional correctness and clean code.
  • The application should run in a modern browser environment.

Out of scope

  • Advanced sorting, filtering, or pagination features.
  • Server-side data synchronization or persistence.
  • Complex accessibility features beyond standard HTML input elements.
  • Extensive styling or UI library integration (e.g., Material UI, Ant Design).
  • Keyboard navigation between cells (only in-cell editing is required).

What interviewers evaluate

  • Architectural Design: How well the component structure is organized, state is managed, and concerns are separated.
  • Core Functionality: Correct implementation of cell editing, data validation, and row management.
  • Code Quality: Readability, maintainability, use of appropriate React patterns (hooks, props, state).
  • Error Handling & UI Feedback: Effectiveness in handling invalid user input and providing clear visual cues.
  • Problem Solving: The approach taken to break down the problem and handle various interactions.

Loading editor...