From ef1e740567118fb371f620f24868ccae8d290969 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 25 May 2024 12:34:16 +0200 Subject: [PATCH] fix: use zero for values when no fit is selected (#132) --- src/components/ShipAttribute/ShipAttribute.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/ShipAttribute/ShipAttribute.tsx b/src/components/ShipAttribute/ShipAttribute.tsx index ddbf83d..9305dda 100644 --- a/src/components/ShipAttribute/ShipAttribute.tsx +++ b/src/components/ShipAttribute/ShipAttribute.tsx @@ -23,14 +23,17 @@ export function useAttribute(type: "Ship" | "Char", props: AttributeProps) { const eveData = useEveData(); const statistics = useStatistics(); - if (eveData === null || statistics === null) return ""; - - const attributeId = eveData.attributeMapping[props.name] ?? 0; let value; - if (type === "Ship") { - value = statistics.hull.attributes.get(attributeId)?.value; + if (eveData === null || statistics === null) { + value = 0; } else { - value = statistics.char.attributes.get(attributeId)?.value; + const attributeId = eveData.attributeMapping[props.name] ?? 0; + + if (type === "Ship") { + value = statistics.hull.attributes.get(attributeId)?.value; + } else { + value = statistics.char.attributes.get(attributeId)?.value; + } } if (value === undefined) {