diff --git a/src/Gang/ui/EquipmentsSubpage.tsx b/src/Gang/ui/EquipmentsSubpage.tsx index b2f53c0d8..664fe9c13 100644 --- a/src/Gang/ui/EquipmentsSubpage.tsx +++ b/src/Gang/ui/EquipmentsSubpage.tsx @@ -3,7 +3,6 @@ */ import React, { useState } from "react"; import { useGang } from "./Context"; -import { generateTableRow } from "./GangMemberStats"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; @@ -22,7 +21,7 @@ import { GangMember } from "../GangMember"; import { UpgradeType } from "../data/upgrades"; import { use } from "../../ui/Context"; import { Settings } from "../../Settings/Settings"; -import { characterOverviewStyles as useStyles } from "../../ui/React/CharacterOverview"; +import { StatsRow } from "../../ui/React/StatsRow"; interface INextRevealProps { upgrades: string[]; @@ -91,7 +90,6 @@ interface IPanelProps { } function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement { - const classes = useStyles(); const gang = useGang(); const player = use.Player(); const setRerender = useState(false)[1]; @@ -178,12 +176,12 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement { > - {generateTableRow("Hacking", props.member.hack, props.member.hack_exp, Settings.theme.hack, classes)} - {generateTableRow("Strength", props.member.str, props.member.str_exp, Settings.theme.combat, classes)} - {generateTableRow("Defense", props.member.def, props.member.def_exp, Settings.theme.combat, classes)} - {generateTableRow("Dexterity", props.member.dex, props.member.dex_exp, Settings.theme.combat, classes)} - {generateTableRow("Agility", props.member.agi, props.member.agi_exp, Settings.theme.combat, classes)} - {generateTableRow("Charisma", props.member.cha, props.member.cha_exp, Settings.theme.cha, classes)} + + + + + +
diff --git a/src/Gang/ui/GangMemberStats.tsx b/src/Gang/ui/GangMemberStats.tsx index 859057837..66fe16582 100644 --- a/src/Gang/ui/GangMemberStats.tsx +++ b/src/Gang/ui/GangMemberStats.tsx @@ -17,36 +17,14 @@ import { import { numeralWrapper } from "../../ui/numeralFormat"; import { GangMember } from "../GangMember"; import { Settings } from "../../Settings/Settings"; -import { formatNumber } from "../../utils/StringHelperFunctions"; import { MoneyRate } from "../../ui/React/MoneyRate"; +import { StatsRow } from "../../ui/React/StatsRow"; import { characterOverviewStyles as useStyles } from "../../ui/React/CharacterOverview"; interface IProps { member: GangMember; } -export const generateTableRow = ( - name: string, - level: number, - exp: number, - color: string, - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - classes: any -): React.ReactElement => { - return ( - - - {name} - - - - {formatNumber(level, 0)} ({numeralWrapper.formatExp(exp)} exp) - - - - ) -} - export function GangMemberStats(props: IProps): React.ReactElement { const classes = useStyles(); @@ -102,12 +80,12 @@ export function GangMemberStats(props: IProps): React.ReactElement { > - {generateTableRow("Hacking", props.member.hack, props.member.hack_exp, Settings.theme.hack, classes)} - {generateTableRow("Strength", props.member.str, props.member.str_exp, Settings.theme.combat, classes)} - {generateTableRow("Defense", props.member.def, props.member.def_exp, Settings.theme.combat, classes)} - {generateTableRow("Dexterity", props.member.dex, props.member.dex_exp, Settings.theme.combat, classes)} - {generateTableRow("Agility", props.member.agi, props.member.agi_exp, Settings.theme.combat, classes)} - {generateTableRow("Charisma", props.member.cha, props.member.cha_exp, Settings.theme.cha, classes)} + + + + + +
diff --git a/src/PersonObjects/Sleeve/ui/StatsElement.tsx b/src/PersonObjects/Sleeve/ui/StatsElement.tsx index c28b898d1..901348a8e 100644 --- a/src/PersonObjects/Sleeve/ui/StatsElement.tsx +++ b/src/PersonObjects/Sleeve/ui/StatsElement.tsx @@ -10,7 +10,7 @@ import { import { numeralWrapper } from "../../../ui/numeralFormat"; import { Settings } from "../../../Settings/Settings"; -import { formatNumber } from "../../../utils/StringHelperFunctions"; +import { StatsRow } from "../../../ui/React/StatsRow"; import { characterOverviewStyles as useStyles } from "../../../ui/React/CharacterOverview"; import { Money } from "../../../ui/React/Money"; import { MoneyRate } from "../../../ui/React/MoneyRate"; @@ -20,44 +20,6 @@ import { use } from "../../../ui/Context"; import { Sleeve } from "../Sleeve"; import { SleeveTaskType } from "../SleeveTaskTypesEnum"; -interface ITableRowData { - content?: string; - level?: number; - exp?: number; -} - -interface IStatsRowProps { - name: string; - color: string; - classes: any; - data: ITableRowData; -} - -export const SleeveStatsRow = ({ name, color, classes, data }: IStatsRowProps): React.ReactElement => { - let content; - - if (data.content !== undefined) { - content = data.content; - } else if (data.level !== undefined && data.exp !== undefined) { - content = `${formatNumber(data.level, 0)} (${numeralWrapper.formatExp(data.exp)} exp)`; - } else if (data.level !== undefined && data.exp === undefined) { - content = `${formatNumber(data.level, 0)}`; - } - - return ( - - - {name} - - - - {content} - - - - ) -} - interface IProps { sleeve: Sleeve; } @@ -68,44 +30,24 @@ export function StatsElement(props: IProps): React.ReactElement { return (
- - + - - - - - - + + + + + +
- - - + + +
) diff --git a/src/ui/React/StatsRow.tsx b/src/ui/React/StatsRow.tsx new file mode 100644 index 000000000..ce623ccd3 --- /dev/null +++ b/src/ui/React/StatsRow.tsx @@ -0,0 +1,49 @@ +import React from "react"; + +import { + Typography, + TableCell, + TableRow, +} from "@mui/material"; + +import { numeralWrapper } from "../numeralFormat"; +import { formatNumber } from "../../utils/StringHelperFunctions"; +import { characterOverviewStyles as useStyles } from "./CharacterOverview"; + +interface ITableRowData { + content?: string; + level?: number; + exp?: number; +} + +interface IProps { + name: string; + color: string; + classes?: any; + data: ITableRowData; +} + +export const StatsRow = ({ name, color, classes = useStyles(), data }: IProps): React.ReactElement => { + let content; + + if (data.content !== undefined) { + content = data.content; + } else if (data.level !== undefined && data.exp !== undefined) { + content = `${formatNumber(data.level, 0)} (${numeralWrapper.formatExp(data.exp)} exp)`; + } else if (data.level !== undefined && data.exp === undefined) { + content = `${formatNumber(data.level, 0)}`; + } + + return ( + + + {name} + + + + {content} + + + + ) +}