import { CPUIcon, HDDIcon, RAMIcon } from "@/components/icons/resource-icons"; import { getDisplayValueFromRAM } from "@/lib/utils/resource-utils"; interface ResourceDisplayProps { title: string; cpu: number | null; ram: number | null; hdd: number | null; } interface IconTextProps { icon: React.ReactNode; label: string; } function IconText({ icon, label }: IconTextProps) { return ( {icon} {label} ); } export function ResourceDisplay({ title, cpu, ram, hdd }: ResourceDisplayProps) { const hasCPU = typeof cpu === "number" && cpu > 0; const hasRAM = typeof ram === "number" && ram > 0; const hasHDD = typeof hdd === "number" && hdd > 0; if (!hasCPU && !hasRAM && !hasHDD) return null; return (
{title}
{hasCPU && } label={`${cpu} vCPU`} />} {hasRAM && } label={getDisplayValueFromRAM(ram!)} />} {hasHDD && } label={`${hdd} GB`} />}
); }