bitburner-src/src/Bladeburner/ui/TeamSizePopup.tsx

46 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-08-16 03:49:08 +02:00
import React, { useState } from "react";
import { removePopup } from "../../ui/React/createPopup";
2021-09-25 20:42:57 +02:00
import { dialogBoxCreate } from "../../ui/React/DialogBox";
2021-08-16 03:49:08 +02:00
import { Action } from "../Action";
import { IBladeburner } from "../IBladeburner";
2021-08-16 03:49:08 +02:00
interface IProps {
2021-09-05 01:09:30 +02:00
bladeburner: IBladeburner;
action: Action;
popupId: string;
2021-08-16 03:49:08 +02:00
}
export function TeamSizePopup(props: IProps): React.ReactElement {
2021-09-05 01:09:30 +02:00
const [teamSize, setTeamSize] = useState<number | undefined>();
function confirmTeamSize(): void {
if (teamSize === undefined) return;
const num = Math.round(teamSize);
if (isNaN(num) || num < 0) {
2021-09-09 05:47:34 +02:00
dialogBoxCreate("Invalid value entered for number of Team Members (must be numeric, positive)");
2021-09-05 01:09:30 +02:00
} else {
props.action.teamCount = num;
2021-08-16 03:49:08 +02:00
}
2021-09-05 01:09:30 +02:00
removePopup(props.popupId);
}
2021-08-16 03:49:08 +02:00
2021-09-05 01:09:30 +02:00
return (
<>
<p>
2021-09-09 05:47:34 +02:00
Enter the amount of team members you would like to take on this Op. If you do not have the specified number of
team members, then as many as possible will be used. Note that team members may be lost during operations.
2021-09-05 01:09:30 +02:00
</p>
<input
autoFocus
type="number"
placeholder="Team size"
className="text-input"
onChange={(event) => setTeamSize(parseFloat(event.target.value))}
/>
<a className="a-link-button" onClick={confirmTeamSize}>
Confirm
</a>
</>
);
}