Merge pull request #3220 from phyzical/bugfix/3214

add similar sort to the faction joined list
This commit is contained in:
hydroflame 2022-03-22 10:41:59 -04:00 committed by GitHub
commit 4c64863314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,7 @@ import { IRouter } from "../../ui/Router";
import { Faction } from "../Faction";
import { joinFaction } from "../FactionHelpers";
import { Factions } from "../Factions";
import { FactionNames } from "../data/FactionNames";
export const InvitationsSeen: string[] = [];
@ -80,6 +81,11 @@ export function FactionsRoot(props: IProps): React.ReactElement {
).length;
}
const allFactions = Object.values(FactionNames).map(faction => faction as string)
const allJoinedFactions = props.player.factions.slice(0);
allJoinedFactions.sort((a, b) =>
allFactions.indexOf(a) - allFactions.indexOf(b));
return (
<Container disableGutters maxWidth="md" sx={{ mx: 0, mb: 10 }}>
<Typography variant="h4">Factions</Typography>
@ -92,11 +98,11 @@ export function FactionsRoot(props: IProps): React.ReactElement {
<Typography variant="h5" color="primary" mt={2} mb={1}>
Factions you have joined:
</Typography>
{(props.player.factions.length > 0 && (
{(allJoinedFactions.length > 0 && (
<Paper sx={{ my: 1, p: 1, pb: 0, display: "inline-block" }}>
<Table padding="none" style={{ width: "fit-content" }}>
<TableBody>
{props.player.factions.map((faction: string) => (
{allJoinedFactions.map((faction: string) => (
<TableRow key={faction}>
<TableCell>
<Typography noWrap mb={1}>