import * as React from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import type { HardwareDatabaseRow, SelectOption } from "@/types/local-frontier"; export type HardwareDatabaseProps = { rows: readonly HardwareDatabaseRow[]; producers: readonly SelectOption[]; priceBands: readonly SelectOption[]; }; function matchesRow( row: HardwareDatabaseRow, search: string, producer: string, priceBand: string, ): boolean { const query = search.trim().toLowerCase(); return ( (!query || row.searchText.includes(query)) && (producer === "all" || row.acceleratorVendorKey === producer) && (priceBand === "all" || row.priceBand === priceBand) ); } function FilterSelect({ label, value, options, onValueChange, }: { label: string; value: string; options: readonly SelectOption[]; onValueChange: (value: string) => void; }): React.JSX.Element { return ( ); } function HardwareRow({ row }: { row: HardwareDatabaseRow }): React.JSX.Element { return ( {row.name} {row.kind} {row.systemVendor} {row.acceleratorVendor} {row.memory} {row.memorySymbol} {row.memoryType} {row.bandwidth} {row.latestPrice} {row.estimated ? ( ) : null} {row.priceBandLabel} {row.evidence} {row.confidence} ); } function HardwareTable({ rows, }: { rows: readonly HardwareDatabaseRow[]; }): React.JSX.Element { if (!rows.length) { return (
No devices match the current filters.
); } return ( Device System vendor Accelerator vendor Memory Bandwidth Latest price Price band Evidence {rows.map((row) => ( ))}
); } export function HardwareDatabase({ rows, producers, priceBands, }: HardwareDatabaseProps): React.JSX.Element { const [search, setSearch] = React.useState(""); const [producer, setProducer] = React.useState("all"); const [priceBand, setPriceBand] = React.useState("all"); const filteredRows = rows.filter((row) => matchesRow(row, search, producer, priceBand), ); return (
); }