feat: add RaceChart
This commit is contained in:
29
src/MVPChart.tsx
Normal file
29
src/MVPChart.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { apiAuth } from "./api";
|
||||
import BarChart from "./BarChart";
|
||||
import { PlayerRanking } from "./types";
|
||||
import RaceChart from "./RaceChart";
|
||||
|
||||
|
||||
const MVPChart = () => {
|
||||
const [data, setData] = useState({} as PlayerRanking[]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [showStd, setShowStd] = useState(false);
|
||||
|
||||
async function loadData() {
|
||||
setLoading(true);
|
||||
await apiAuth("analysis/mvp", null)
|
||||
.then(json => json as Promise<PlayerRanking[]>).then(json => { setData(json.sort((a, b) => a.rank - b.rank)) })
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
useEffect(() => { loadData() }, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
{loading ? <span className="loader" /> : <RaceChart std={showStd} players={data} />
|
||||
}
|
||||
</>)
|
||||
}
|
||||
|
||||
export default MVPChart;
|
Reference in New Issue
Block a user