import { Button, ButtonGroup, Checkbox, FormControlLabel, InputLabel, MenuItem, Select, SelectChangeEvent, } from "@mui/material"; import Head from "next/head"; import Link from "../components/Link"; import { useContext, useState } from "react"; import Menu from "../components/Menu"; import { GetStaticProps } from "next"; import { TranslateContext } from "../Modules/context"; import db from "#/Modules/database"; import { useRouter } from "next/router"; import { getData } from "./api/theme"; type historicalTimes = { [Key: string]: number[] }; interface props { historicalTimes: historicalTimes; leagues: string[]; league_enabled: { [Key: string]: boolean }; } type fileTypes = "json" | "csv"; export default function Home({ historicalTimes, leagues, league_enabled, }: props) { const [matchday, setMatchday] = useState(0); const [showHidden, setShowHidden] = useState(false); const [league, setLeague] = useState(leagues[0]); // Used to handle when the league selected changes const changeLeague = (e: SelectChangeEvent) => { setLeague(e.target.value); setMatchday(0); }; const router = useRouter(); const t = useContext(TranslateContext); // Generates the download link function downloadLink(type: fileTypes) { return `/api/download?type=${type}&league=${league}${ matchday !== 0 ? `&time=${matchday}` : "" }${showHidden ? "&showHidden=true" : ""}&locale=${router.locale}`; } return ( <> {t("Download Data")}

{t("Download Data")}

{t("Here you can download the player data for personal use. ")} {t("This downloaded player data is only available in english. ")}

{leagues.length > 0 && ( <> {t("Time")} {t("League")}
{!league_enabled[league] && (

{t("Note that this league is not updated anymore.")}

)}