mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 12:27:07 +02:00
HASHNET: Company Favor (#469)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Creates a dropdown (select HTML element) with company names as options
|
||||
*/
|
||||
import React from "react";
|
||||
import { companiesMetadata } from "../../Company/data/CompaniesMetadata";
|
||||
|
||||
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import Button from "@mui/material/Button";
|
||||
|
||||
interface IProps {
|
||||
purchase: () => void;
|
||||
canPurchase: boolean;
|
||||
onChange: (event: SelectChangeEvent<string>) => void;
|
||||
value: string;
|
||||
}
|
||||
|
||||
const sortedCompanies = companiesMetadata.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
export function CompanyDropdown(props: IProps): React.ReactElement {
|
||||
const companies = [];
|
||||
for (const company of sortedCompanies) {
|
||||
companies.push(
|
||||
<MenuItem key={company.name} value={company.name}>
|
||||
{company.name}
|
||||
</MenuItem>,
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Select
|
||||
startAdornment={
|
||||
<Button onClick={props.purchase} disabled={!props.canPurchase}>
|
||||
Buy
|
||||
</Button>
|
||||
}
|
||||
sx={{ mx: 1 }}
|
||||
value={props.value}
|
||||
onChange={props.onChange}
|
||||
>
|
||||
{companies}
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user