Make a heirarchical tree component which has Employee and Manger relation in ReactJs

Viewed 20

I have a Js object which has both manager IDs and employee IDs, I want to create a ReactJs Tree component that shows all the managers and their employees. So if I click on a manager it should expand and show all the employees reporting to him/her. How can I do it using Material UI Tree view or any other way?

The object looks like:

const empMangerData= [{emp_id: 'EMP001', manager_id: ''},
 {emp_id: 'EMP002', manager_id: 'EMP001'},
 {emp_id: 'EMP003', manager_id: 'EMP001'},
 {emp_id: 'EMP004', manager_id: 'EMP002'},
 {emp_id: 'EMP005', manager_id: 'EMP002'}
 {…}]

This is an example of what I want

This is an example of what I want

1 Answers
Related