CORPORATION: Check there is room to make a new product before opening popup. (#147)

This commit is contained in:
G4mingJon4s 2022-10-24 14:58:51 +02:00 committed by GitHub
parent e9e9ac1def
commit 3861e56ced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,6 +33,11 @@ function MakeProductButton(): React.ReactElement {
return Object.keys(division.products).length === 0;
}
function onButtonClick() {
if (hasMaxProducts) return;
setMakeOpen(true);
}
let createProductButtonText = "";
switch (division.type) {
case Industries.Food:
@ -78,7 +83,7 @@ function MakeProductButton(): React.ReactElement {
)
}
>
<Button color={shouldFlash() ? "error" : "primary"} onClick={() => setMakeOpen(true)} disabled={corp.funds < 0}>
<Button color={shouldFlash() ? "error" : "primary"} onClick={onButtonClick} disabled={corp.funds < 0}>
{createProductButtonText}
</Button>
</Tooltip>