Overview
At PhonePe, understanding our organizational structure is crucial for collaboration and growth. We need an intuitive tool that allows employees to visualize reporting lines and navigate through the company hierarchy. This problem focuses on building a front-end component to display an interactive organizational chart, making it easy to see who reports to whom and access employee details.
What you need to do / Task
Your task is to build a React component that displays an organizational chart based on a given flat list of employee data. The component should be interactive and meet the following requirements:
- Render Hierarchy: Display employees in a hierarchical structure, visually representing their reporting lines.
- Employee Cards: Each employee should be represented by a clickable 'card' displaying their name and designation.
- Expand/Collapse Functionality: For any employee who is a manager (i.e., has direct reports), provide a toggle to expand or collapse their direct reports. Initially, only the top-level employee(s) and their direct reports should be visible.
- Employee Details View: When an employee card is clicked, their full details (e.g., ID, name, designation, manager ID) should be displayed in a dedicated section of the UI.
UI/UX expectations
- The organizational structure should be clearly visible, possibly using indentation or visual connectors to denote hierarchy.
- Expand/collapse toggles should be intuitive (e.g.,
+/- icons or arrow icons).
- The currently selected employee's card should be visually distinct (e.g., different background color, border).
- A dedicated, clearly labeled area should display the detailed information of the selected employee.
- The overall layout should be clean and easy to understand.
Acceptance criteria
- The root employee(s) and their immediate direct reports are visible on initial load.
- Clicking a manager's expand/collapse toggle correctly shows/hides their direct reports and all subsequent subordinates.
- The full hierarchy renders correctly when all nodes are expanded.
- Clicking any employee card updates the details panel with accurate information for that employee.
- The UI remains responsive and free of console errors during interactions.
- The solution is implemented using functional React components and hooks.