Skip to content

Commit

Permalink
fix(device-page): fitler devices in select
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusds committed Feb 2, 2024
1 parent 9c8a877 commit 4d9dbc7
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/components/device-page/header-device-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,17 @@ export function HeaderDeviceSelector(props: HeaderDeviceSelectorProps): JSX.Elem
</Dropdown.Toggle>

<Dropdown.Menu as={SearchMenu} searchTerm={searchTerm} t={t} setSearchTerm={setSearchTerm}>
<HeaderDeviceSelectorItems devices={devices} dev={dev} tab={tab} setSearchTerm={setSearchTerm} />
{HeaderDeviceSelectorItems({ devices, dev, tab, setSearchTerm })}
</Dropdown.Menu>
</Dropdown>
</h1>
);
}

function HeaderDeviceSelectorItems({ devices, dev, tab, setSearchTerm }: HeaderDeviceSelectorItemsProps): JSX.Element {
return (
<>
{Object.entries(devices).map(([id, device]) => (
<Dropdown.Item
active={id === dev}
key={id}
href={`#/device/${id}/${tab}`}
onClick={() => setSearchTerm('')}
>
{device.friendly_name}
</Dropdown.Item>
))}
</>
);
function HeaderDeviceSelectorItems({ devices, dev, tab, setSearchTerm }: HeaderDeviceSelectorItemsProps) {
return Object.entries(devices).map(([id, device]) => (
<Dropdown.Item active={id === dev} key={id} href={`#/device/${id}/${tab}`} onClick={() => setSearchTerm('')}>
{device.friendly_name}
</Dropdown.Item>
));
}

0 comments on commit 4d9dbc7

Please sign in to comment.