{slots.map((slot, idx) => {
- const deviceList = Object.entries(devices).map(([type, items]) => {
- const device = titlecase(type);
- return {
- label: device,
- options: (items as any[]).map(({ _id, label }) => {
- return { label, value: _id };
- }),
- value: type,
- };
- });
+ const deviceList = Object.entries(devices).reduce(
+ (acc, [type, items]) => {
+ const device = titlecase(type);
+ const options = (items as any[]).map(({ _id, label }) => {
+ return { deviceType: device, label, value: _id };
+ });
+ return [...acc, ...options];
+ },
+ []
+ );
deviceList.unshift({
- label: '',
- options: [{ label: 'None', value: null }],
- value: '',
+ deviceType: '',
+ label: 'None',
+ value: null,
});
- const selectedDevice = getSelectedOptionFromGroupedOptions(
+ const selectedDevice = getSelectedDeviceOption(
getSelected(slot),
deviceList
);
return counter < idx ? null : (
-