-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show ban status on player history card (#317)
- Loading branch information
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
rcongui/src/components/PlayersHistory/PlayerTile/PlayerBan.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from "react"; | ||
import { Grid, Typography } from "@material-ui/core"; | ||
import { fromJS } from "immutable"; | ||
import { reduce } from "lodash"; | ||
|
||
export function banListFromServer(data) { | ||
return fromJS( | ||
reduce( | ||
data, | ||
(acc, val) => { | ||
if (!acc.hasOwnProperty(val.steam_id_64)) { | ||
acc[val.steam_id_64] = new Array(val) | ||
} else { | ||
acc[val.steam_id_64].push(val) | ||
} | ||
return acc; | ||
}, | ||
{} | ||
) | ||
); | ||
} | ||
|
||
|
||
export const PlayerBan = ({ classes, bans, player }) => { | ||
const playerBans = bans.get(player.get('steam_id_64')) | ||
const formattedBans = {} | ||
|
||
playerBans?.forEach(b => b.get('type') === 'temp' ? formattedBans.temp = 'IS TEMP BANNED' : formattedBans.perma = 'IS PERMA BANNED') | ||
return ( | ||
<Grid | ||
container | ||
justify="space-between" | ||
spacing={0} | ||
className={classes.noPaddingMargin} | ||
> | ||
<Grid item xs={6}> | ||
{formattedBans.temp ? | ||
<Typography variant="h7" color="secondary">{formattedBans.temp}</Typography> | ||
: "" | ||
} | ||
</Grid> | ||
<Grid item xs={6}> | ||
{formattedBans.perma ? | ||
<Typography variant="h7" color="secondary">{formattedBans.perma}</Typography> | ||
: "" | ||
} | ||
</Grid> | ||
</Grid> | ||
|
||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters