diff --git a/app/account/page.tsx b/app/account/page.tsx index 756f287..14a2e98 100644 --- a/app/account/page.tsx +++ b/app/account/page.tsx @@ -13,6 +13,9 @@ import updateProfileType from "@/utils/firebase/db/updateProfileType"; import deleteAccount from "@/utils/firebase/account/deleteAccount"; import googleSignOut from "@/utils/firebase/account/googleSignOut"; import { useRouter } from "next/navigation"; +import getAverageScore from "@/utils/score/getAverageScore"; +import countTotalSplits from "@/utils/score/countTotalSplits"; +import StatBox from "@/components/account/statBox"; export default function History() { // general @@ -21,6 +24,13 @@ export default function History() { const { user } = useAuthContext() as { user: any }; const router = useRouter(); + // stats + const [averageScore, setAverageScore] = useState(0); + const [highScore, setHighScore] = useState(0); + const [lowScore, setLowScore] = useState(0); + const [totalGames, setTotalGames] = useState(0); + const [totalSplits, setTotalSplits] = useState(0); + // account const [name, setName] = useState(""); const [namePlaceholder, setNamePlaceholder] = useState(""); @@ -39,6 +49,11 @@ export default function History() { setUserDoc(doc); setNamePlaceholder(doc.displayName); setProfileType(doc.profileType); + setAverageScore(getAverageScore(doc.allScores)); + setTotalSplits(countTotalSplits(doc.allScores)); + setTotalGames(doc.allScores.length); + setHighScore(doc.highScore); + setLowScore(doc.lowScore); }); }, []); @@ -77,7 +92,15 @@ export default function History() { selected={currentWindow == "account" ? true : false} /> - {currentWindow == "stats" ?