From 2f2923dd8b88b3114411b5e187f2255b927dd075 Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Sat, 11 Sep 2021 13:27:40 -0700 Subject: [PATCH] Stop remounting on corp overview Make upgrade buttons real buttons --- .eslintrc.js | 1 - css/companymanagement.scss | 1 + src/Corporation/ui/LevelableUpgrade.tsx | 4 +- src/Corporation/ui/Overview.tsx | 626 ++++++++++++------------ src/Corporation/ui/UnlockUpgrade.tsx | 4 +- 5 files changed, 327 insertions(+), 309 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cc4da5ace..d6c323f4a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -63,7 +63,6 @@ module.exports = { "id-blacklist": ["error"], "id-length": ["off"], "id-match": ["error"], - "implicit-arrow-linebreak": ["error", "beside"], indent: ["off"], "indent-legacy": ["off"], "init-declarations": ["off"], diff --git a/css/companymanagement.scss b/css/companymanagement.scss index 13e2ccdcc..6919c1bb4 100644 --- a/css/companymanagement.scss +++ b/css/companymanagement.scss @@ -133,6 +133,7 @@ } .cmpy-mgmt-upgrade-div { + text-align: left; display: inline-block; border: 1px solid #fff; margin: 2px; diff --git a/src/Corporation/ui/LevelableUpgrade.tsx b/src/Corporation/ui/LevelableUpgrade.tsx index 3fa536788..3d4ef2df0 100644 --- a/src/Corporation/ui/LevelableUpgrade.tsx +++ b/src/Corporation/ui/LevelableUpgrade.tsx @@ -40,9 +40,9 @@ export function LevelableUpgrade(props: IProps): React.ReactElement { } return ( -
+
+ ); } diff --git a/src/Corporation/ui/Overview.tsx b/src/Corporation/ui/Overview.tsx index 570e47dbe..2807c42be 100644 --- a/src/Corporation/ui/Overview.tsx +++ b/src/Corporation/ui/Overview.tsx @@ -27,330 +27,52 @@ interface IProps { player: IPlayer; rerender: () => void; } - -export function Overview(props: IProps): React.ReactElement { - // Generic Function for Creating a button - interface ICreateButtonProps { - text: string; - class?: string; - className?: string; - display?: string; - tooltip?: string; - onClick?: (event: React.MouseEvent) => void; - } - - function Button(props: ICreateButtonProps): React.ReactElement { - let className = props.className ? props.className : "std-button"; - const hasTooltip = props.tooltip != null; - if (hasTooltip) className += " tooltip"; - return ( - - {props.text} - {hasTooltip && {props.tooltip}} - - ); - } - - function openBribeFactionPopup(): void { - const popupId = "corp-bribe-popup"; - createPopup(popupId, BribeFactionPopup, { - player: props.player, - popupId: popupId, - corp: props.corp, - }); - } - - const profit: number = props.corp.revenue.minus(props.corp.expenses).toNumber(); - - function DividendsStats(): React.ReactElement { - if (props.corp.dividendPercentage <= 0 || profit <= 0) return <>; - const totalDividends = (props.corp.dividendPercentage / 100) * profit; - const retainedEarnings = profit - totalDividends; - const dividendsPerShare = totalDividends / props.corp.totalShares; - const playerEarnings = props.corp.numShares * dividendsPerShare; - return ( - <> - Retained Profits (after dividends): / s
-
- Dividend Percentage: {numeralWrapper.format(props.corp.dividendPercentage / 100, "0%")} -
- Dividends per share: / s
- Your earnings as a shareholder (Pre-Tax): / s
- Dividend Tax Rate: {props.corp.dividendTaxPercentage}%
- Your earnings as a shareholder (Post-Tax):{" "} - / s
-
- - ); - } - - function Mult(props: { name: string; mult: number }): React.ReactElement { - if (props.mult <= 1) return <>; - return ( -

- {props.name} - {numeralWrapper.format(props.mult, "0.000")} -
-

- ); - } - - // Returns a string with general information about Corporation - function BonusTime(): React.ReactElement { - const storedTime = props.corp.storedCycles * CONSTANTS.MilliPerCycle; - if (storedTime <= 15000) return <>; - return ( -

- Bonus time: {convertTimeMsToTimeElapsedString(storedTime)} -
-
-

- ); - } - - function BribeButton(): React.ReactElement { - const canBribe = props.corp.determineValuation() >= CorporationConstants.BribeThreshold || true; - const bribeFactionsClass = canBribe ? "a-link-button" : "a-link-button-inactive"; - return ( - + ); +} + +interface IBribeButtonProps { + player: IPlayer; + corp: ICorporation; +} +function BribeButton({ player, corp }: IBribeButtonProps): React.ReactElement { + function openBribeFactionPopup(): void { + const popupId = "corp-bribe-popup"; + createPopup(popupId, BribeFactionPopup, { + player, + popupId, + corp: corp, + }); + } + + const canBribe = corp.determineValuation() >= CorporationConstants.BribeThreshold || true; + const bribeFactionsClass = canBribe ? "a-link-button" : "a-link-button-inactive"; + return ( + ); }