mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-06 05:17:37 +01:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
|
import React, { useState } from "react";
|
||
|
|
||
|
import { Location } from "../Location";
|
||
|
import { createPurchaseServerPopup,
|
||
|
createUpgradeHomeCoresPopup,
|
||
|
purchaseTorRouter } from "../LocationsHelpers";
|
||
|
|
||
|
import { CONSTANTS } from "../../Constants";
|
||
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||
|
import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";
|
||
|
|
||
|
import { StdButtonPurchased } from "../../ui/React/StdButtonPurchased";
|
||
|
import { StdButton } from "../../ui/React/StdButton";
|
||
|
import { Money } from "../../ui/React/Money";
|
||
|
|
||
|
type IProps = {
|
||
|
p: IPlayer;
|
||
|
}
|
||
|
|
||
|
export function TorButton(props: IProps): React.ReactElement {
|
||
|
const setRerender = useState(false)[1];
|
||
|
function rerender(): void {
|
||
|
setRerender(old => !old);
|
||
|
}
|
||
|
|
||
|
const btnStyle = { display: "block" };
|
||
|
|
||
|
function buy(): void {
|
||
|
purchaseTorRouter(props.p);
|
||
|
rerender();
|
||
|
}
|
||
|
|
||
|
if(props.p.hasTorRouter()) {
|
||
|
return (<StdButtonPurchased
|
||
|
style={btnStyle}
|
||
|
text={"TOR Router - Purchased"}
|
||
|
/>);
|
||
|
}
|
||
|
|
||
|
return (<StdButton
|
||
|
disabled={!props.p.canAfford(CONSTANTS.TorRouterCost)}
|
||
|
onClick={buy}
|
||
|
style={btnStyle}
|
||
|
text={<>Purchase TOR router - {Money(CONSTANTS.TorRouterCost)}</>}
|
||
|
/>);
|
||
|
}
|