Overview
At Freshworks, understanding team structures and reporting lines is crucial for effective collaboration and management. Visualizing these hierarchies helps employees navigate the organization and understand their place within it. Your task is to build an interactive organizational chart viewer that can display employee relationships and allow users to explore different departments.
What you need to do / Task
- Data Transformation: Convert a flat list of
Employee objects (each with an id and managerId) into a hierarchical tree structure suitable for rendering.
- Render Org Chart: Display the employee hierarchy, starting from the top-level managers (employees with no
managerId or whose managerId is not found in the list).
- Expand/Collapse Functionality: Implement the ability to expand and collapse sub-teams. Initially, all root-level employees should be visible, and their direct reports should be collapsed.
- Employee Details: Each employee node should clearly display at least their
name and title.
UI/UX expectations
- Hierarchy Visualization: Use indentation or other visual cues (e.g., lines) to clearly represent the reporting structure.
- Expand/Collapse Indicator: An intuitive indicator (e.g., an arrow or +/- icon) should be displayed next to employees who have direct reports. This indicator should visually change to reflect the current expanded/collapsed state.
- Interactivity: Clicking the indicator should toggle the visibility of that employee's direct reports.
- Readability: Nodes should be reasonably sized and spaced for good readability.
Acceptance criteria
- The application renders without any console errors.
- All employees from the provided dataset are correctly displayed within the hierarchy.
- Employees without a
managerId (or whose managerId does not correspond to an existing employee) are correctly identified and rendered as root nodes.
- Each employee node clearly displays their
name and title.
- Clicking an expand/collapse indicator correctly toggles the visibility of immediate direct reports.
- The initial state correctly displays all root nodes, with their direct reports and subsequent levels collapsed.