bitburner-src/src/ui/React/SoftResetButton.tsx

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-04-07 01:30:08 +02:00
import React, { useState } from "react";
import { ConfirmationModal } from "./ConfirmationModal";
import Button from "@mui/material/Button";
2022-04-07 01:30:08 +02:00
import { Tooltip } from "@mui/material";
import RestartAltIcon from "@mui/icons-material/RestartAlt";
interface IProps {
color?: "primary" | "warning" | "error";
noConfirmation?: boolean;
onTriggered: () => void;
}
2022-04-07 01:30:08 +02:00
export function SoftResetButton({
color = "primary",
noConfirmation = false,
onTriggered,
}: IProps): React.ReactElement {
const [modalOpened, setModalOpened] = useState(false);
function handleButtonClick(): void {
if (noConfirmation) {
onTriggered();
} else {
setModalOpened(true);
}
}
2022-04-07 01:30:08 +02:00
return (
<>
<Tooltip title="Perform a soft reset. Resets everything as if you had just installed Augmentations without installing them.">
2022-04-07 01:30:08 +02:00
<Button startIcon={<RestartAltIcon />} color={color} onClick={handleButtonClick}>
Soft Reset
</Button>
</Tooltip>
<ConfirmationModal
onConfirm={onTriggered}
open={modalOpened}
onClose={() => setModalOpened(false)}
confirmationText={"This will perform the same action as installing Augmentations, are you sure?"}
/>
</>
);
}