From e9b8da408a679708d835871635a5f6778cbec252 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Fri, 10 May 2024 18:29:59 +0200 Subject: [PATCH] fix: render less statistics for Structures (#93) --- .storybook/fits.ts | 45 +++++++ src/ShipFitExtended/ShipFitExtended.tsx | 9 +- src/ShipStatistics/ShipStatistics.tsx | 155 ++++++++++++------------ 3 files changed, 133 insertions(+), 76 deletions(-) diff --git a/.storybook/fits.ts b/.storybook/fits.ts index 78751fc..e71a3ec 100644 --- a/.storybook/fits.ts +++ b/.storybook/fits.ts @@ -147,6 +147,51 @@ export const fullFits = [ { flag: 128, quantity: 1, type_id: 45621 }, ], }, + { + ship_type_id: 35833, + name: "Killmail 117621358", + description: "", + items: [ + { flag: 5, type_id: 37821, quantity: 6 }, + { flag: 5, type_id: 37822, quantity: 7 }, + { flag: 5, type_id: 37823, quantity: 7 }, + { flag: 5, type_id: 37824, quantity: 7 }, + { flag: 5, type_id: 37843, quantity: 6102 }, + { flag: 5, type_id: 37844, quantity: 4249 }, + { flag: 5, type_id: 63195, quantity: 17200 }, + { flag: 11, type_id: 47362, quantity: 1 }, + { flag: 12, type_id: 47342, quantity: 1 }, + { flag: 13, type_id: 47362, quantity: 1 }, + { flag: 14, type_id: 47362, quantity: 1 }, + { flag: 19, type_id: 35944, quantity: 1 }, + { flag: 20, type_id: 47334, quantity: 1 }, + { flag: 21, type_id: 47366, quantity: 1 }, + { flag: 22, type_id: 47338, quantity: 1 }, + { flag: 23, type_id: 47338, quantity: 1 }, + { flag: 27, type_id: 47327, quantity: 1 }, + { flag: 28, type_id: 47323, quantity: 1 }, + { flag: 29, type_id: 47323, quantity: 1 }, + { flag: 30, type_id: 47323, quantity: 1 }, + { flag: 31, type_id: 47330, quantity: 1 }, + { flag: 32, type_id: 47330, quantity: 1 }, + { flag: 92, type_id: 37254, quantity: 1 }, + { flag: 93, type_id: 37258, quantity: 1 }, + { flag: 94, type_id: 37260, quantity: 1 }, + { flag: 158, type_id: 47035, quantity: 10 }, + { flag: 158, type_id: 47037, quantity: 10 }, + { flag: 158, type_id: 47119, quantity: 12 }, + { flag: 158, type_id: 47123, quantity: 6 }, + { flag: 158, type_id: 47127, quantity: 6 }, + { flag: 158, type_id: 47127, quantity: 6 }, + { flag: 158, type_id: 47136, quantity: 3 }, + { flag: 158, type_id: 47141, quantity: 2 }, + { flag: 158, type_id: 47141, quantity: 6 }, + { flag: 158, type_id: 47143, quantity: 9 }, + { flag: 164, type_id: 35894, quantity: 1 }, + { flag: 172, type_id: 4246, quantity: 14030 }, + { flag: 180, type_id: 56204, quantity: 1 }, + ], + }, ]; export const fullFit = fullFits[2]; diff --git a/src/ShipFitExtended/ShipFitExtended.tsx b/src/ShipFitExtended/ShipFitExtended.tsx index 381ff60..e62d0ee 100644 --- a/src/ShipFitExtended/ShipFitExtended.tsx +++ b/src/ShipFitExtended/ShipFitExtended.tsx @@ -8,6 +8,7 @@ import { ShipSnapshotContext } from "../ShipSnapshotProvider"; import styles from "./ShipFitExtended.module.css"; import clsx from "clsx"; import { DroneBay } from "../DroneBay"; +import { EveDataContext } from "../EveDataProvider"; const ShipCargoHold = () => { return ( @@ -27,8 +28,13 @@ const ShipCargoHold = () => { }; const ShipDroneBay = () => { + const eveData = React.useContext(EveDataContext); + const shipSnapshot = React.useContext(ShipSnapshotContext); + const [isOpen, setIsOpen] = React.useState(false); + const isStructure = eveData.typeIDs?.[shipSnapshot?.hull?.type_id ?? 0]?.categoryID === 65; + return ( <>
setIsOpen(!isOpen)} className={styles.droneBay}> @@ -40,7 +46,8 @@ const ShipDroneBay = () => {
- / + / {isStructure && <>0.0} + {!isStructure && }
m3
diff --git a/src/ShipStatistics/ShipStatistics.tsx b/src/ShipStatistics/ShipStatistics.tsx index 32059a4..7f9be3c 100644 --- a/src/ShipStatistics/ShipStatistics.tsx +++ b/src/ShipStatistics/ShipStatistics.tsx @@ -21,6 +21,7 @@ export const ShipStatistics = () => { const shipSnapshot = React.useContext(ShipSnapshotContext); let capacitorState = "Stable"; + const isStructure = eveData.typeIDs?.[shipSnapshot?.hull?.type_id ?? 0]?.categoryID === 65; if (shipSnapshot?.loaded) { const attributeId = eveData.attributeMapping?.capacitorDepletesIn || 0; @@ -220,94 +221,98 @@ export const ShipStatistics = () => { - - m/s - - } - > - - + {!isStructure && ( + - + m/s - - t + } + > + + + + + + + t + - - - - + + + + + + x + - - x + + + + + + + + AU/s + - - - - - - + + + + + + s + - - AU/s - - - - - - - - s - - - - + + + )} - - dps - - } - > - - + {!isStructure && ( + - + dps - - / - Mbit/sec + } + > + + + + + + + / + Mbit/sec + - - - - + + + + + + km + - - km + + + + +
+
+ + Active +
- -
- - - -
+ + + - - Active - -
- - - - -
-
+ + + )} ); };