bitburner-src/src/DevMenu/ui/CodingContractsDev.tsx

60 lines
2.1 KiB
TypeScript
Raw Normal View History

2021-09-14 02:37:35 +02:00
import React, { useState } from "react";
2021-09-17 01:23:03 +02:00
import Accordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary";
import AccordionDetails from "@mui/material/AccordionDetails";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
2021-09-14 02:37:35 +02:00
2021-10-01 22:22:33 +02:00
import Typography from "@mui/material/Typography";
2021-09-17 01:23:03 +02:00
import Button from "@mui/material/Button";
import Select, { SelectChangeEvent } from "@mui/material/Select";
import MenuItem from "@mui/material/MenuItem";
2021-09-14 04:27:43 +02:00
import { generateContract, generateRandomContract, generateRandomContractOnHome } from "../../CodingContractGenerator";
2021-09-14 02:37:35 +02:00
import { CodingContractTypes } from "../../CodingContracts";
export function CodingContractsDev(): React.ReactElement {
2021-09-14 02:37:35 +02:00
const [codingcontract, setCodingcontract] = useState("Find Largest Prime Factor");
function setCodingcontractDropdown(event: SelectChangeEvent): void {
setCodingcontract(event.target.value);
2021-09-14 02:37:35 +02:00
}
function specificContract(): void {
generateContract({
problemType: codingcontract,
server: "home",
});
}
return (
2021-09-18 03:30:02 +02:00
<Accordion TransitionProps={{ unmountOnExit: true }}>
2021-09-14 02:37:35 +02:00
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
2021-10-01 22:22:33 +02:00
<Typography>Coding Contracts</Typography>
2021-09-14 02:37:35 +02:00
</AccordionSummary>
<AccordionDetails>
<table>
<tbody>
<tr>
<td>
<Button onClick={generateRandomContract}>Generate Random Contract</Button>
<Button onClick={generateRandomContractOnHome}>Generate Random Contract on Home Comp</Button>
</td>
</tr>
<tr>
<td>
2021-09-15 03:05:49 +02:00
<Select onChange={setCodingcontractDropdown} value={codingcontract}>
2021-09-14 02:37:35 +02:00
{Object.values(CodingContractTypes).map((cc) => (
<MenuItem key={cc.name} value={cc.name}>
{cc.name}
</MenuItem>
))}
</Select>
<Button onClick={specificContract}>Generate Specified Contract Type on Home Comp</Button>
</td>
</tr>
</tbody>
</table>
</AccordionDetails>
</Accordion>
);
}