Frontend School

Interactive Salesforce Org Chart Viewer

Machine Coding
medium

Interactive Salesforce Org Chart Viewer

Medium
React
TypeScript
Tree
UI
Component

Overview

Salesforce applications often require intuitive ways to visualize complex data structures. One common need is to display an organization's hierarchy, allowing users to quickly understand team structures and reporting lines. In this problem, you will build a dynamic Org Chart component that visualizes employee relationships in a tree-like structure, enabling users to explore the hierarchy by expanding and collapsing teams.

What you need to do / Task

Your primary goal is to create a React component that displays an interactive organizational chart based on a flat list of employee data.

  1. Render the Org Chart Root: Display the top-level employee (CEO/President) as the root of the chart.
  2. Display Employee Details: For each employee, render their name and title.
  3. Implement Expand/Collapse:
    • If an employee has direct reports, render a toggle (e.g., + / - icon or an arrow) next to their name.
    • Clicking this toggle should expand or collapse their direct reports.
  4. Visualize Hierarchy: Direct reports should be visually nested (e.g., indented) under their manager to clearly indicate the reporting structure.
  5. Initial State: The chart should initially render with only the top-level manager's direct reports expanded. All other subsequent levels should be collapsed by default.

UI/UX expectations

  • Clear Visual Hierarchy: Use indentation or similar visual cues to distinguish managers from their direct reports.
  • Intuitive Toggles: The expand/collapse mechanism should be clear and easy to interact with (e.g., a clickable icon). Consider using aria-expanded for accessibility.
  • Minimalist Design: Focus on functionality and clarity. Basic styling is sufficient.

Acceptance criteria

  • The component renders without errors and displays the top-level employee.
  • Each employee's name and title are displayed correctly.
  • Employees with direct reports show an expand/collapse toggle.
  • Clicking an expand toggle reveals the direct reports, nested correctly.
  • Clicking a collapse toggle hides the direct reports.
  • The initial render correctly shows only the top-level manager's direct reports expanded, with all other branches collapsed.
  • All employees from the provided mock data can be reached by expanding their respective managers.

Constraints

Constraints & assumptions

  • You must use React with TypeScript.
  • The input data will be a flat array of Employee objects, where each employee has a managerId (or null for the top-level employee).
  • The maximum depth of the organizational tree will not exceed 5-7 levels.
  • The total number of employees will be relatively small (~20-30), so performance for extremely large datasets is not the primary focus.
  • You are free to use functional components and React Hooks.
  • Styling can be basic; focus on structure and functionality.

Out of scope

  • Implementing search, filtering, or sorting functionality.
  • Drag-and-drop reordering of employees.
  • Advanced styling or theming.
  • Integration with a backend API (use provided mock data).

What interviewers evaluate

  • Ability to process and render hierarchical data effectively.
  • Proficiency in React component design, state management, and props drilling/context.
  • Clean, well-structured, and maintainable TypeScript code.
  • Implementation of interactive UI elements and basic accessibility considerations.

Loading editor...