I need to build the sequence of dependent dropdowns based on the following JSON structure:
[
{
id: 1,
label: 'Opt 1',
data: [
{
id: 11,
label: 'Opt 1.1',
data: [
{
id: 111,
label: 'Opt 1.1.1'
},
{
id: 112,
label: 'Opt 1.1.2',
data: [
{
id: 1121,
label: 'Opt 1.1.2.1'
},
{
id: 1122,
label: 'Opt 1.1.2.2'
}
]
}
]
}
]
},
{
id: 2,
label: 'Opt 2',
data: [
{
id: 21,
label: 'Option 2.1'
},
{
id: 22,
label: 'Option 2.2'
}
]
}
];
Examples of how it is expected to work:
Scenario 1
- Dropdown
[Opt 1, Opt 2]
is displayed. - Select
Opt 1
from dropdown - Dropdown
[Opt 1.1]
is being added. - Select
Opt 1.1
- Dropdown
[Opt 1.1.1, Opt 1.1.2]
is being displayed - Dropdown
[Opt 1.1.2.1, Opt 1.1.2.2]
is being displayed - Select any option from the previous step dropdown, END.
Scenario 2
- Dropdown
[Opt 1, Opt 2]
is displayed. - Select
Opt 2
from dropdown - Dropdown
[Opt 2.1, Opt 2.2]
is being displayed - Select any option from the previous step dropdown, END.
Honestly, I'm stuck with this problem and have no idea about how to approach it, any help will be appreciated.