import { useState } from 'react' import { getManufacturerName } from 'lib/seam/components/SupportedDevices/device-models.js' import type { Manufacturer } from 'lib/seam/ecosystem/types.js' import { BrandMark } from './BrandMark.js' import { DeviceRow } from './DeviceRow.js' import type { PresentedDevice } from './presentation.js' /** Device models shown per manufacturer before the show all button. */ const collapsedCount = 5 interface ManufacturerSectionProps { devices: PresentedDevice[] manufacturer: Manufacturer | null collapsible: boolean } export function ManufacturerSection({ devices, manufacturer, collapsible, }: ManufacturerSectionProps): JSX.Element { const [expanded, setExpanded] = useState(false) const canExpand = collapsible && devices.length > collapsedCount const visibleDeviceModels = canExpand && !expanded ? devices.slice(0, collapsedCount) : devices const name = manufacturer != null ? getManufacturerName(manufacturer) : devices[0]?.source.manufacturer != null ? getManufacturerName(devices[0].source.manufacturer) : t.other return (

{name}

{t.count(devices.length)}
Device & supported capabilities
{visibleDeviceModels.map((deviceModel) => ( ))}
{canExpand && (
)}
) } const t = { other: 'Other devices', count: (count: number) => `${count} ${count === 1 ? 'device' : 'devices'}`, showAll: (name: string, count: number) => `Show all ${count} ${name} devices`, showLess: 'Show less', }