diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index d044867e8..e69d5bd72 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -233,9 +233,9 @@ export function SetSmartSupply(warehouse: Warehouse, smartSupply: boolean): void } export function SetSmartSupplyUseLeftovers(warehouse: Warehouse, material: Material, useLeftover: boolean): void { - if (!Object.keys(warehouse.smartSupplyUseLeftovers).includes(material.name)) + if (!Object.keys(warehouse.smartSupplyUseLeftovers).includes(material.name.replace(/ /g, ""))) throw new Error(`Invalid material '${material.name}'`); - warehouse.smartSupplyUseLeftovers[material.name] = useLeftover; + warehouse.smartSupplyUseLeftovers[material.name.replace(/ /g, "")] = useLeftover; } export function BuyMaterial(material: Material, amt: number): void { diff --git a/src/Corporation/ui/SmartSupplyModal.tsx b/src/Corporation/ui/SmartSupplyModal.tsx index b4c031d99..083fb8ed5 100644 --- a/src/Corporation/ui/SmartSupplyModal.tsx +++ b/src/Corporation/ui/SmartSupplyModal.tsx @@ -16,7 +16,7 @@ interface ILeftoverProps { } function Leftover(props: ILeftoverProps): React.ReactElement { - const [checked, setChecked] = useState(!!props.warehouse.smartSupplyUseLeftovers[props.matName]); + const [checked, setChecked] = useState(!!props.warehouse.smartSupplyUseLeftovers[props.matName.replace(/ /g, "")]); function onChange(event: React.ChangeEvent): void { try { @@ -33,7 +33,7 @@ function Leftover(props: ILeftoverProps): React.ReactElement { <> } - label={{props.warehouse.materials[props.matName].name}} + label={{props.warehouse.materials[props.matName.replace(/ /g, "")].name}} />