Skip to content

Commit

Permalink
fix: use zero for values when no fit is selected (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain authored May 25, 2024
1 parent b7252fa commit ef1e740
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/ShipAttribute/ShipAttribute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ef1e740

Please sign in to comment.