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

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