-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
797efc3
commit 11a9a94
Showing
9 changed files
with
203 additions
and
94 deletions.
There are no files selected for viewing
File renamed without changes.
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,12 @@ | ||
import Request from "config-request"; | ||
|
||
export async function getTopPlayers() { | ||
return new Promise((resolve, reject) => { | ||
Request.get("/top", {}, function (err, data) { | ||
if (err) { | ||
reject(err); | ||
} | ||
resolve(data ? data : null); | ||
}); | ||
}); | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,72 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { getTopPlayers } from "../../api/top"; | ||
|
||
import Grid from "@material-ui/core/Grid"; | ||
import List from "@material-ui/core/List"; | ||
import ListItem from "@material-ui/core/ListItem"; | ||
import ListItemText from "@material-ui/core/ListItemText"; | ||
import Paper from "@material-ui/core/Paper"; | ||
import Typography from "@material-ui/core/Typography"; | ||
|
||
import { useUserState } from "../auth"; | ||
import StandardPage from "./standard-page"; | ||
|
||
export default function TopPlayers() { | ||
const [topPlayerData, setTopPlayerData] = useState([]); | ||
useEffect(() => { | ||
async function fetchData() { | ||
const data = await getTopPlayers(); | ||
setTopPlayerData(data); | ||
} | ||
fetchData(); | ||
}, []); | ||
|
||
const [{ user }] = useUserState(); | ||
|
||
return ( | ||
<StandardPage> | ||
<Typography variant="h2" gutterBottom> | ||
{`Top Players`} | ||
</Typography> | ||
<List> | ||
<ListItem> | ||
<Grid container> | ||
<Grid item xs={1}> | ||
<Typography variant="h6">Rank</Typography> | ||
</Grid> | ||
<Grid item xs={5}> | ||
<Typography variant="h5">Player Name</Typography> | ||
</Grid> | ||
<Grid item xs={5}> | ||
<Typography variant="h6">MMR</Typography> | ||
</Grid> | ||
</Grid> | ||
</ListItem> | ||
{topPlayerData.map((player, i) => ( | ||
<ListItem key={player.steamid}> | ||
<Grid container> | ||
<Grid item xs={1}> | ||
<Typography variant="h6">{i + 1}</Typography> | ||
</Grid> | ||
<Grid item xs={5}> | ||
{user.steamid === player.steamid && ( | ||
<Typography variant="h5"> | ||
<strong> | ||
<i>{player.name}</i> | ||
</strong> | ||
</Typography> | ||
)} | ||
{user.steamid !== player.steamid && ( | ||
<Typography variant="h5">{player.name}</Typography> | ||
)} | ||
</Grid> | ||
<Grid item xs={5}> | ||
<Typography variant="h6">{player.mmr.toFixed(2)}</Typography> | ||
</Grid> | ||
</Grid> | ||
</ListItem> | ||
))} | ||
</List> | ||
</StandardPage> | ||
); | ||
} |
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