fix some React errors

This commit is contained in:
Olivier Gagnon 2022-07-21 15:24:03 -04:00
parent 2d522ea1e6
commit 5c551348ed
3 changed files with 33 additions and 32 deletions

@ -232,7 +232,7 @@ export function FactionsRoot(props: IProps): React.ReactElement {
sx={{ sx={{
gap: 1, gap: 1,
gridTemplateColumns: (invitations.length > 0 ? "1fr " : "") + "2fr", gridTemplateColumns: (invitations.length > 0 ? "1fr " : "") + "2fr",
[theme.breakpoints.down("lg")]: { gridTemplateColumns: "1fr", "& > span:nth-child(1)": { order: 1 } }, [theme.breakpoints.down("lg")]: { gridTemplateColumns: "1fr", "& > span:nth-of-type(1)": { order: 1 } },
gridTemplateRows: "minmax(0, 1fr)", gridTemplateRows: "minmax(0, 1fr)",
"& > span > .MuiBox-root": { "& > span > .MuiBox-root": {
display: "grid", display: "grid",

@ -15,7 +15,6 @@ export function process(this: IPlayer, cycles = 1): void {
} }
} }
export function finish(this: IPlayer, cancelled: boolean): void { export function finish(this: IPlayer, cancelled: boolean): void {
console.error("finishing");
if (this.currentWork === null) return; if (this.currentWork === null) return;
this.currentWork.finish(this, cancelled); this.currentWork.finish(this, cancelled);
this.currentWork = null; this.currentWork = null;

@ -87,37 +87,39 @@ export function ProgramsRoot(): React.ReactElement {
sx={{ p: 1, opacity: player.hasProgram(program.name) ? 0.75 : 1 }} sx={{ p: 1, opacity: player.hasProgram(program.name) ? 0.75 : 1 }}
key={program.name} key={program.name}
> >
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}> <>
{(player.hasProgram(program.name) && <Check sx={{ mr: 1 }} />) || <Typography variant="h6" sx={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
(create.req(player) && <Create sx={{ mr: 1 }} />) || <Lock sx={{ mr: 1 }} />} {(player.hasProgram(program.name) && <Check sx={{ mr: 1 }} />) ||
{program.name} (create.req(player) && <Create sx={{ mr: 1 }} />) || <Lock sx={{ mr: 1 }} />}
</Typography> {program.name}
{!player.hasProgram(program.name) && create.req(player) && (
<Button
sx={{ my: 1, width: "100%" }}
onClick={(event) => {
if (!event.isTrusted) return;
player.startWork(
new CreateProgramWork({ player: player, singularity: false, programName: program.name }),
);
player.startFocusing();
router.toWork();
}}
>
Create program
</Button>
)}
{player.hasProgram(program.name) || getHackingLevelRemaining(create.level) === 0 || (
<Typography color={Settings.theme.hack}>
<b>Unlocks in:</b> {getHackingLevelRemaining(create.level)} hacking levels
</Typography> </Typography>
)} {!player.hasProgram(program.name) && create.req(player) && (
{curCompletion !== -1 && ( <Button
<Typography color={Settings.theme.infolight}> sx={{ my: 1, width: "100%" }}
<b>Current completion:</b> {curCompletion}% onClick={(event) => {
</Typography> if (!event.isTrusted) return;
)} player.startWork(
<Typography>{create.tooltip}</Typography> new CreateProgramWork({ player: player, singularity: false, programName: program.name }),
);
player.startFocusing();
router.toWork();
}}
>
Create program
</Button>
)}
{player.hasProgram(program.name) || getHackingLevelRemaining(create.level) === 0 || (
<Typography color={Settings.theme.hack}>
<b>Unlocks in:</b> {getHackingLevelRemaining(create.level)} hacking levels
</Typography>
)}
{curCompletion !== -1 && (
<Typography color={Settings.theme.infolight}>
<b>Current completion:</b> {curCompletion}%
</Typography>
)}
<Typography>{create.tooltip}</Typography>
</>
</Box> </Box>
); );
})} })}