diff --git a/src/Route/Index/Index.jsx b/src/Route/Index/Index.jsx index 518eb4e..b22dcc0 100644 --- a/src/Route/Index/Index.jsx +++ b/src/Route/Index/Index.jsx @@ -6,6 +6,7 @@ import { useEffect, useState } from 'react'; function Index() { const [charts, setCharts] = useState([]); + const [scores, setScores] = useState([]); const getCharts = async () => { const db = getFirestore(); @@ -16,10 +17,23 @@ function Index() { return charts; } + const getScores = async () => { + const db = getFirestore(); + const scoreRef = collection(db, "Score"); + const snapshot = await getDocs(scoreRef); + const scores = snapshot.docs.map(doc => doc.data()); + + return scores; + } + + useEffect(() => { async function fetchData() { - const data = await getCharts(); - setCharts(data); + const charts = await getCharts(); + setCharts(charts); + + const scores = await getScores(); + setScores(scores); } fetchData(); }, []); @@ -27,8 +41,8 @@ function Index() { return (
-
- Yuki +
+ Yuki
@@ -36,10 +50,10 @@ function Index() { {charts.length} Charts - 0 Score + {scores.length} Score
-
+

Welcome to MaiScore, a website that allows you to view your score from Maimai. You will be able to submit your score for each chart and see other score from other players.