UI: Infiltration rewards default to the faction you're currently working for (#1114)

* Better infiltration victory faction default
* Better condition for "none" default
* Fix default faction type.
This commit is contained in:
LJ 2024-02-28 17:37:27 -07:00 committed by GitHub
parent 6288eec6d7
commit 4c7f192645
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -17,6 +17,7 @@ import {
calculateTradeInformationRepReward,
} from "../formulas/victory";
import { getEnumHelper } from "../../utils/EnumHelper";
import { isFactionWork } from "../../Work/FactionWork";
interface IProps {
StartingDifficulty: number;
@ -26,7 +27,8 @@ interface IProps {
}
export function Victory(props: IProps): React.ReactElement {
const [factionName, setFactionName] = useState("none");
const defaultFaction = isFactionWork(Player.currentWork) ? Player.currentWork.factionName : "none";
const [factionName, setFactionName] = useState(defaultFaction);
function quitInfiltration(): void {
handleInfiltrators();
@ -79,9 +81,11 @@ export function Victory(props: IProps): React.ReactElement {
<Box sx={{ width: "fit-content" }}>
<Box sx={{ width: "100%" }}>
<Select value={factionName} onChange={changeDropdown} sx={{ mr: 1 }}>
<MenuItem key={"none"} value={"none"}>
{"none"}
</MenuItem>
{defaultFaction === "none" && (
<MenuItem key={"none"} value={"none"}>
{"none"}
</MenuItem>
)}
{Player.factions
.filter((f) => Factions[f].getInfo().offersWork())
.map((f) => (