Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DeviceModelV1 } from '@seamapi/types/devicedb'
import { useMemo } from 'react'

import { SupportedDeviceFilterResultRow } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.js'
import { SupportedDeviceManufacturerSection } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.js'
Expand Down Expand Up @@ -33,6 +34,11 @@ export function SupportedDeviceContent({
}
)

const groupedDeviceModels = useMemo(
() => groupDeviceModelsByManufacturer(deviceModels ?? []),
[deviceModels]
)

if (isLoading) {
return (
<div className='seam-supported-device-table-content-state-block'>
Expand Down Expand Up @@ -91,15 +97,22 @@ export function SupportedDeviceContent({

return (
<>
{Object.entries(groupDeviceModelsByManufacturer(deviceModels)).map(
([manufacturerId, models]) => (
<SupportedDeviceManufacturerSection
key={manufacturerId}
manufacturerId={manufacturerId}
deviceModels={models}
/>
{Object.entries(groupedDeviceModels)
.sort(
(e1, e2) =>
e1[1][0]?.manufacturer.display_name.localeCompare(
e2[1][0]?.manufacturer.display_name ?? ''
) ?? 0
)
)}
.map(([manufacturerId, models]) => {
return (
<SupportedDeviceManufacturerSection
key={manufacturerId}
manufacturerId={manufacturerId}
deviceModels={models}
/>
)
})}
</>
)
}
Expand Down Expand Up @@ -136,9 +149,9 @@ function EmptyResult({
)
}

function groupDeviceModelsByManufacturer(
const groupDeviceModelsByManufacturer = (
deviceModels: UseDeviceModelsData
): Record<string, DeviceModelV1[]> {
): Record<string, DeviceModelV1[]> => {
const result: Record<string, DeviceModelV1[]> = {}

for (const model of deviceModels) {
Expand Down