Align columns in warehouse storage breakdown (#970)

This commit is contained in:
Jesse Clark 2023-12-27 21:25:57 -08:00 committed by GitHub
parent e096456c29
commit 1dac133ef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,6 +22,7 @@ import { purchaseWarehouse } from "../Actions";
import { useCorporation, useDivision } from "./Context"; import { useCorporation, useDivision } from "./Context";
import { gameCyclesPerCorpStateCycle } from "../data/Constants"; import { gameCyclesPerCorpStateCycle } from "../data/Constants";
import { ButtonWithTooltip } from "../../ui/Components/ButtonWithTooltip"; import { ButtonWithTooltip } from "../../ui/Components/ButtonWithTooltip";
import { StatsTable } from "../../ui/React/StatsTable";
interface WarehouseProps { interface WarehouseProps {
corp: Corporation; corp: Corporation;
@ -95,25 +96,21 @@ function WarehouseRoot(props: WarehouseProps): React.ReactElement {
} }
} }
const breakdownItems: string[] = []; const breakdownItems: string[][] = [];
for (const matName of corpConstants.materialNames) { for (const matName of corpConstants.materialNames) {
const mat = props.warehouse.materials[matName]; const mat = props.warehouse.materials[matName];
if (mat.stored === 0) continue; if (mat.stored === 0) continue;
breakdownItems.push(`${matName}: ${formatMaterialSize(mat.stored * MaterialInfo[matName].size)}`); breakdownItems.push([`${matName}:`, `${formatMaterialSize(mat.stored * MaterialInfo[matName].size)}`]);
} }
for (const [prodName, product] of division.products) { for (const [prodName, product] of division.products) {
breakdownItems.push( breakdownItems.push([
`${prodName}: ${formatMaterialSize(product.cityData[props.currentCity].stored * product.size)}`, `${prodName}:`,
); `${formatMaterialSize(product.cityData[props.currentCity].stored * product.size)}`,
]);
} }
let breakdown; const breakdown = breakdownItems.length > 0 ? <StatsTable rows={breakdownItems} /> : <>No items in storage.</>;
if (breakdownItems.length > 0) {
breakdown = breakdownItems.map((item, i) => <p key={i}>{item}</p>);
} else {
breakdown = <>No items in storage.</>;
}
return ( return (
<Paper> <Paper>