Fix for AI Cores in smart supply

This commit is contained in:
pigalot 2022-01-13 22:21:05 +00:00
parent 6ee291e0b3
commit bd20f16a2d
2 changed files with 4 additions and 4 deletions

@ -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 {

@ -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<HTMLInputElement>): void {
try {
@ -33,7 +33,7 @@ function Leftover(props: ILeftoverProps): React.ReactElement {
<>
<FormControlLabel
control={<Switch checked={checked} onChange={onChange} />}
label={<Typography>{props.warehouse.materials[props.matName].name}</Typography>}
label={<Typography>{props.warehouse.materials[props.matName.replace(/ /g, "")].name}</Typography>}
/>
<br />
</>