Frontend School

Zepto Delivery Schedule Gantt Chart

Machine Coding
medium

Zepto Delivery Schedule Gantt Chart

Medium
Gantt Chart
UI
React
Frontend
Scheduling

Overview

At Zepto, efficient delivery operations are crucial. Operations managers need a clear, visual representation of delivery agents' schedules to quickly identify task assignments, potential overlaps, and optimize routes. This problem challenges you to build a simplified, read-only Gantt chart view for delivery tasks, allowing managers to visualize agent workloads over a fixed time window.

What you need to do / Task

Your primary goal is to render a functional Gantt chart based on provided mock data. Specifically, you must:

  1. Render a Timeline Header: Display a time axis at the top of the chart, showing time intervals (e.g., every 30 minutes) for the defined chart duration.
  2. Display Agent Rows: For each delivery agent in the mockAgents data, create a dedicated row that clearly labels the agent's name.
  3. Render Task Bars: Within each agent's row, visualize their assigned tasks as horizontal bars. The position and width of each task bar must accurately reflect its startTime and endTime relative to the overall chart timeline.
  4. Implement Task Details on Hover: When a user hovers over a task bar, display a small tooltip or inline text showing the task's name and its full startTime to endTime range.

UI/UX expectations

  • Layout: The chart should have a clear header for the timeline and distinct rows for each agent. Tasks should be rendered as distinct rectangular bars within their respective agent rows.
  • Readability: Ensure the time labels are legible and task bars are visually distinct (e.g., different background colors or borders).
  • Interactivity: The hover effect for task details should be smooth and clearly present the required information.
  • Responsiveness: While a fully responsive layout is not required, the chart should render reasonably well within the provided sandpack viewport without horizontal scrolling (assume a fixed width for the overall chart container).

Acceptance criteria

  • The timeline header correctly displays time units (e.g., 9:00, 9:30, 10:00, etc.) for the entire chart duration.
  • Each agent's row is clearly labeled with their name.
  • Task bars are rendered within their corresponding agent rows.
  • The horizontal position of each task bar accurately corresponds to its startTime on the timeline.
  • The width of each task bar accurately represents its duration (endTime - startTime).
  • Hovering over any task bar displays its name and the startTime - endTime range.
  • The application runs without console errors and handles the provided mock data.

Constraints

Constraints & assumptions

  • Chart Time Window: The Gantt chart must visualize tasks within a fixed time window from 09:00 to 14:00 (5 hours total).
  • Task Durations: All tasks will have a minimum duration of 15 minutes.
  • Data Structure: You must use the provided Agent and Task interfaces and mockAgents data.
  • Fixed Layout: Assume a fixed total width for the Gantt chart container (e.g., 1000px or similar, you can define this in CSS or inline style) for calculating pixel-based positioning and widths.
  • No Editing: The chart is read-only; no drag-and-drop, resizing, or creation of tasks is required.
  • Environment: React (TypeScript) for the frontend.

Out of scope

  • Backend integration or API calls.
  • Complex date/time library usage (basic string parsing for 'HH:MM' is sufficient).
  • Scrolling timeline or dynamic time range selection.
  • Advanced collision detection or visualization for overlapping tasks within the same agent's row (tasks should just render as distinct bars on top of each other if they overlap, focus on positioning).
  • Real-time updates or WebSocket integration.

What interviewers evaluate

  • Correctness: Accurate calculation and rendering of time-based UI elements.
  • Code Quality: Clean, modular, and readable React component structure with appropriate use of state and props.
  • Problem Solving: Logical approach to converting time data into visual layout properties (position, width).
  • UI Implementation: Attention to detail in meeting UI/UX expectations, including basic styling and interactivity.

Loading editor...