-
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
c7029bb
commit 5374805
Showing
8 changed files
with
244 additions
and
149 deletions.
There are no files selected for viewing
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,31 @@ | ||
import React, { useEffect, useState } from "react"; | ||
|
||
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 Match from './match'; | ||
import { useUserState } from "./auth"; | ||
import { getUser } from "../api/user"; | ||
|
||
export default function MatchHistory({ userProfile }) { | ||
if (!userProfile) { | ||
return null; | ||
} | ||
|
||
// grab the 100 at the end of the array, they're the most recent | ||
const recentMatches = userProfile.matches.length > 100 ? userProfile.matches.slice(userProfile.matches.length - 100) : userProfile.matches | ||
|
||
return ( | ||
<List> | ||
{recentMatches.reverse().map((matchId) => ( | ||
<ListItem key={matchId}> | ||
<Match matchId={matchId} userId={userProfile.steamid} /> | ||
</ListItem> | ||
))} | ||
</List> | ||
); | ||
} |
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
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
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,46 @@ | ||
import React, { useState, useEffect } from "react"; | ||
|
||
import { useParams } from "react-router-dom"; | ||
|
||
import Typography from "@material-ui/core/Typography"; | ||
|
||
import StandardPage from './standard-page'; | ||
import { useUserState } from "../auth"; | ||
import UserInfo from '../user-info'; | ||
import MatchHistory from '../match-history'; | ||
import { getUser } from "../../api/user"; | ||
|
||
function Overview() { | ||
const [{ user }] = useUserState(); | ||
const { userId = user.steamid } = useParams(); | ||
const [userProfile, setUserProfile] = useState(null); | ||
|
||
console.log({ userId }); | ||
|
||
useEffect(() => { | ||
async function fetchData() { | ||
const userData = getUser(userId); | ||
|
||
setUserProfile(await userData); | ||
} | ||
fetchData(); | ||
}, [userId]); | ||
|
||
if (!userProfile) { | ||
return <StandardPage />; | ||
} | ||
|
||
return ( | ||
<StandardPage> | ||
<UserInfo userId={userId} userProfile={userProfile} /> | ||
<br /> | ||
<br /> | ||
<Typography variant="h2"> | ||
Match History | ||
</Typography> | ||
<MatchHistory userProfile={userProfile} /> | ||
</StandardPage> | ||
); | ||
} | ||
|
||
export default Overview; |
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
Oops, something went wrong.