Merge pull request #3486 from phyzical/bugfix/3485

UI FIX #3485 - Allow bulk purchasing when smart supply is enabled
This commit is contained in:
hydroflame 2022-05-04 12:10:00 -04:00 committed by GitHub
commit a88d79ef0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

@ -162,11 +162,7 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement {
<Tooltip <Tooltip
title={tutorial ? <Typography>Purchase your required materials to get production started!</Typography> : ""} title={tutorial ? <Typography>Purchase your required materials to get production started!</Typography> : ""}
> >
<Button <Button color={tutorial ? "error" : "primary"} onClick={() => setPurchaseMaterialOpen(true)}>
color={tutorial ? "error" : "primary"}
onClick={() => setPurchaseMaterialOpen(true)}
disabled={props.warehouse.smartSupplyEnabled && Object.keys(division.reqMats).includes(props.mat.name)}
>
{purchaseButtonText} {purchaseButtonText}
</Button> </Button>
</Tooltip> </Tooltip>
@ -174,6 +170,9 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement {
mat={mat} mat={mat}
warehouse={warehouse} warehouse={warehouse}
open={purchaseMaterialOpen} open={purchaseMaterialOpen}
disablePurchaseLimit={
props.warehouse.smartSupplyEnabled && Object.keys(division.reqMats).includes(props.mat.name)
}
onClose={() => setPurchaseMaterialOpen(false)} onClose={() => setPurchaseMaterialOpen(false)}
/> />

@ -106,6 +106,7 @@ interface IProps {
onClose: () => void; onClose: () => void;
mat: Material; mat: Material;
warehouse: Warehouse; warehouse: Warehouse;
disablePurchaseLimit: boolean;
} }
// Create a popup that lets the player purchase a Material // Create a popup that lets the player purchase a Material
@ -143,6 +144,7 @@ export function PurchaseMaterialModal(props: IProps): React.ReactElement {
<Typography> <Typography>
Enter the amount of {props.mat.name} you would like to purchase per second. This material's cost changes Enter the amount of {props.mat.name} you would like to purchase per second. This material's cost changes
constantly. constantly.
{props.disablePurchaseLimit ? "Note: Purchase amount is disabled as smart supply is enabled" : ""}
</Typography> </Typography>
<TextField <TextField
value={buyAmt} value={buyAmt}
@ -150,10 +152,15 @@ export function PurchaseMaterialModal(props: IProps): React.ReactElement {
autoFocus={true} autoFocus={true}
placeholder="Purchase amount" placeholder="Purchase amount"
type="number" type="number"
disabled={props.disablePurchaseLimit}
onKeyDown={onKeyDown} onKeyDown={onKeyDown}
/> />
<Button onClick={purchaseMaterial}>Confirm</Button> <Button disabled={props.disablePurchaseLimit} onClick={purchaseMaterial}>
<Button onClick={clearPurchase}>Clear Purchase</Button> Confirm
</Button>
<Button disabled={props.disablePurchaseLimit} onClick={clearPurchase}>
Clear Purchase
</Button>
{division.hasResearch("Bulk Purchasing") && ( {division.hasResearch("Bulk Purchasing") && (
<BulkPurchaseSection onClose={props.onClose} mat={props.mat} warehouse={props.warehouse} /> <BulkPurchaseSection onClose={props.onClose} mat={props.mat} warehouse={props.warehouse} />
)} )}