import type { DeviceModel, ManufacturerAnnotation, } from '@seamapi/types/devicedb' import classNames from 'classnames' import { ChevronRightIcon } from 'lib/icons/ChevronRight.js' import { InfoBlueIcon } from 'lib/icons/InfoBlue.js' import { HiddenDevicesOverlay } from 'lib/seam/components/SupportedDeviceTable/HiddenDevicesOverlay.js' import { ShowAllDevicesButton } from 'lib/seam/components/SupportedDeviceTable/ShowAllDevicesButton.js' import { SupportedDeviceRow } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceRow.js' import { useManufacturer } from 'lib/seam/components/SupportedDeviceTable/use-manufacturer.js' import { useToggle } from 'lib/ui/use-toggle.js' /** * How many device models required before collapsing the list, * and requiring the user to click to view all. */ const maxDevicesBeforeCollapsing = 3 interface SupportedDeviceManufacturerSectionProps { manufacturerId: string deviceModels: DeviceModel[] } export function SupportedDeviceManufacturerSection({ manufacturerId, deviceModels, }: SupportedDeviceManufacturerSectionProps): JSX.Element | null { const { manufacturer } = useManufacturer({ manufacturer_id: manufacturerId }) const [expanded, toggleExpand] = useToggle() const canExpand = deviceModels.length > maxDevicesBeforeCollapsing const visibleDevices = !canExpand || expanded ? deviceModels : deviceModels.filter( (_deviceModel, index) => index < maxDevicesBeforeCollapsing ) const handleHeaderClick = (): void => { if (!canExpand) { return } toggleExpand() } return (
{manufacturer?.display_name}
{manufacturer?.display_name} {t.devices}
{canExpand && }
{manufacturer?.annotations.map((annotation, idx) => ( ))}
{visibleDevices.map((deviceModel) => ( ))}
) } function ManufacturerAnnotationBox({ annotation, }: { annotation: ManufacturerAnnotation }): JSX.Element { return (

{annotation.message}

) } const t = { devices: 'Devices', }