diff --git a/src/Corporation/ui/CorporationUIEventHandler.js b/src/Corporation/ui/CorporationUIEventHandler.js index 3b3013d09..e95942560 100644 --- a/src/Corporation/ui/CorporationUIEventHandler.js +++ b/src/Corporation/ui/CorporationUIEventHandler.js @@ -56,29 +56,6 @@ export class CorporationEventHandler { this.routing = routing; } - // Create a popup that lets the player discontinue a product - createDiscontinueProductPopup(product, industry) { - const popupId = "cmpy-mgmt-discontinue-product-popup"; - const txt = createElement("p", { - innerText:"Are you sure you want to do this? Discontinuing a product " + - "removes it completely and permanently. You will no longer " + - "produce this product and all of its existing stock will be " + - "removed and left unsold", - }); - const confirmBtn = createElement("button", { - class:"popup-box-button",innerText:"Discontinue", - clickListener: () => { - industry.discontinueProduct(product); - removeElementById(popupId); - this.rerender(); - return false; - }, - }); - const cancelBtn = createPopupCloseButton(popupId, { innerText: "Cancel" }); - - createPopup(popupId, [txt, cancelBtn, confirmBtn]); - } - // Create a popup that lets the player manage exports createExportMaterialPopup(mat) { const corp = this.corp; diff --git a/src/Corporation/ui/DiscontinueProductPopup.tsx b/src/Corporation/ui/DiscontinueProductPopup.tsx new file mode 100644 index 000000000..8c814c8e5 --- /dev/null +++ b/src/Corporation/ui/DiscontinueProductPopup.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import { removePopup } from "../../ui/React/createPopup"; + +interface IProps { + product: any; + industry: any; + corp: any; + popupId: string; +} + +// Create a popup that lets the player discontinue a product +export function DiscontinueProductPopup(props: IProps): React.ReactElement { + function discontinue() { + props.industry.discontinueProduct(props.product); + removePopup(props.popupId); + props.corp.rerender(); + } + + return (<> +

+Are you sure you want to do this? Discontinuing a product +removes it completely and permanently. You will no longer +produce this product and all of its existing stock will be +removed and left unsold

+ + ); +} \ No newline at end of file diff --git a/src/Corporation/ui/IndustryWarehouse.tsx b/src/Corporation/ui/IndustryWarehouse.tsx index 3a56ddc9c..86f2867f0 100644 --- a/src/Corporation/ui/IndustryWarehouse.tsx +++ b/src/Corporation/ui/IndustryWarehouse.tsx @@ -7,9 +7,11 @@ import { OfficeSpace } from "../OfficeSpace"; import { Material } from "../Material"; import { Product } from "../Product"; import { Warehouse } from "../Warehouse"; +import { DiscontinueProductPopup } from "./DiscontinueProductPopup"; import { numeralWrapper } from "../../ui/numeralFormat"; import { dialogBoxCreate } from "../../../utils/DialogBox"; +import { createPopup } from "../../ui/React/createPopup"; import { isString } from "../../../utils/helpers/isString"; @@ -71,8 +73,15 @@ function ProductComponent(props: IProductProps) { } const limitProductionButtonOnClick = eventHandler.createLimitProductProdutionPopup.bind(eventHandler, product, city); - // Discontinue Button - const discontinueButtonOnClick = eventHandler.createDiscontinueProductPopup.bind(eventHandler, product, division); + function openDiscontinueProductPopup() { + const popupId = "cmpy-mgmt-discontinue-product-popup"; + createPopup(popupId, DiscontinueProductPopup, { + product: product, + industry: division, + corp: props.corp, + popupId: popupId, + }); + } // Market TA button const marketTaButtonOnClick = eventHandler.createProductMarketTaPopup.bind(eventHandler, product, division); @@ -93,7 +102,7 @@ function ProductComponent(props: IProductProps) { - { @@ -173,7 +182,7 @@ function ProductComponent(props: IProductProps) { - { diff --git a/src/DevMenu.jsx b/src/DevMenu.jsx index c158e9f32..5f0e6caea 100644 --- a/src/DevMenu.jsx +++ b/src/DevMenu.jsx @@ -584,6 +584,13 @@ class DevMenuComponent extends Component { } } + finishCorporationProducts() { + if(!Player.corporation) return; + Player.corporation.divisions.forEach(div => { + Object.keys(div.products).forEach(prod => div.products[prod].prog = 99.9) + }); + } + specificContract() { generateContract({ problemType: this.state.codingcontract, @@ -1169,6 +1176,11 @@ class DevMenuComponent extends Component { /> + + + + +