UI: Revealed faction augments remaining in faction invite. (#357)

This commit is contained in:
Zelow79 2023-02-11 10:41:50 -05:00 committed by GitHub
parent 07b1eefe33
commit 1f5546b721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,20 +12,10 @@ import { Factions } from "../Factions";
export const InvitationsSeen: string[] = []; export const InvitationsSeen: string[] = [];
const getAugsLeft = (faction: Faction): number => {
const augs = getFactionAugmentationsFiltered(faction);
return augs.filter((augmentation: string) => !Player.hasAugmentation(augmentation)).length;
};
interface IWorkTypeProps {
faction: Faction;
}
const fontSize = "small"; const fontSize = "small";
const marginRight = 0.5; const marginRight = 0.5;
const WorkTypesOffered = (props: IWorkTypeProps): React.ReactElement => { const WorkTypesOffered = (props: { faction: Faction }): React.ReactElement => {
const info = props.faction.getInfo(); const info = props.faction.getInfo();
return ( return (
@ -49,16 +39,16 @@ const WorkTypesOffered = (props: IWorkTypeProps): React.ReactElement => {
); );
}; };
interface IFactionProps { interface FactionElementProps {
faction: Faction; faction: Faction;
/** Whether the player is a member of this faction already */
joined: boolean; joined: boolean;
/** Rerender function to force the entire FactionsRoot to rerender */
rerender: () => void; rerender: () => void;
} }
const FactionElement = (props: FactionElementProps): React.ReactElement => {
const FactionElement = (props: IFactionProps): React.ReactElement => {
const facInfo = props.faction.getInfo(); const facInfo = props.faction.getInfo();
const augsLeft = getFactionAugmentationsFiltered(props.faction).filter((aug) => !Player.hasAugmentation(aug)).length;
function openFaction(faction: Faction): void { function openFaction(faction: Faction): void {
Router.toFaction(faction); Router.toFaction(faction);
@ -114,12 +104,11 @@ const FactionElement = (props: IFactionProps): React.ReactElement => {
alignItems: "center", alignItems: "center",
}} }}
> >
<span <Tooltip title={props.faction.name}>
style={{ overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }} <span style={{ overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }}>
title={props.faction.name} {props.faction.name}
> </span>
{props.faction.name} </Tooltip>
</span>
<span style={{ display: "flex", alignItems: "center" }}> <span style={{ display: "flex", alignItems: "center" }}>
{Player.hasGangWith(props.faction.name) && ( {Player.hasGangWith(props.faction.name) && (
@ -156,12 +145,7 @@ const FactionElement = (props: IFactionProps): React.ReactElement => {
<span style={{ display: "flex", alignItems: "center" }}> <span style={{ display: "flex", alignItems: "center" }}>
{!Player.hasGangWith(props.faction.name) && <WorkTypesOffered faction={props.faction} />} {!Player.hasGangWith(props.faction.name) && <WorkTypesOffered faction={props.faction} />}
<Typography variant="body2" sx={{ display: "flex" }}>{`${augsLeft || "No"} Augmentations left`}</Typography>
{props.joined && (
<Typography variant="body2" sx={{ display: "flex" }}>
{getAugsLeft(props.faction)} Augmentations left
</Typography>
)}
</span> </span>
</span> </span>
</Box> </Box>