From 623854b7373f174056f58f4f98128239d4c0067f Mon Sep 17 00:00:00 2001 From: Aryan Kothari Date: Mon, 25 Dec 2023 23:15:58 +0000 Subject: [PATCH] display to screen --- frontend/pages/index.tsx | 36 ++++++++++++++++++++++-- frontend/pages/season/[seasonNumber].tsx | 27 +++++++++++++++++- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index e8134c49..191aae67 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -22,10 +22,34 @@ type SeasonData = { [key: string]: SingleChart; } +type StdDevs = { + DAMAGE: number; + SUPPORT: number; + TANK: number; +} + + +const HeroStdDev = ({value, role}: {value: number, role: string}) => { + return ( +
+
{role}
+
{Math.round((value + Number.EPSILON) * 100) / 100}
-const Index = ({data, season_list}: { data: SeasonData, season_list: string[]}) => { +
+ ) +} + +const Index = ({data, season_list, std_devs}: { data: SeasonData, season_list: string[], std_devs: StdDevs}) => { return ( <> + + + + + + + + {Object.keys(data).map(key => { if (key.includes("O_ALL")){ @@ -74,21 +98,29 @@ const Index = ({data, season_list}: { data: SeasonData, season_list: string[]}) export async function getServerSideProps(context: GetServerSidePropsContext) { + const seasonNumber = "7" + // Make an API call using seasonNumber - const res = await fetch(`http://server:8000/chart/7_8`); + const res = await fetch(`http://server:8000/chart/${seasonNumber}_8`); const data = await res.json(); const res2 = await fetch("http://server:8000/d/seasons") const season_list = await res2.json() + const res3 = await fetch(`http://server:8000/d/single_season_std_by_role/${seasonNumber}_8`) + const std_devs = await res3.json() + return { props: { data, season_list, + std_devs }, }; } + + export default Index \ No newline at end of file diff --git a/frontend/pages/season/[seasonNumber].tsx b/frontend/pages/season/[seasonNumber].tsx index 7bec0c11..b62e4821 100644 --- a/frontend/pages/season/[seasonNumber].tsx +++ b/frontend/pages/season/[seasonNumber].tsx @@ -23,10 +23,31 @@ type SeasonData = { [key: string]: SingleChart; } +type StdDevs = { + DAMAGE: number; + SUPPORT: number; + TANK: number; +} -const Season = ({data, season_list}: { data: SeasonData, season_list: string[]}) => { +const HeroStdDev = ({value, role}: {value: number, role: string}) => { + return ( +
+
{role}
+
{Math.round((value + Number.EPSILON) * 100) / 100}
+ +
+ ) +} + +const Season = ({data, season_list, std_devs}: { data: SeasonData, season_list: string[], std_devs: StdDevs}) => { return ( <> + + + + + + {Object.keys(data).map(key => { if (key.includes("O_ALL")){ @@ -85,10 +106,14 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { const res2 = await fetch("http://server:8000/d/seasons") const season_list = await res2.json() + const res3 = await fetch(`http://server:8000/d/single_season_std_by_role/${seasonNumber}_8`) + const std_devs = await res3.json() + return { props: { data, season_list, + std_devs }, }; }