import React, { useMemo } from "react"; import { useQuery } from "react-query"; import axios from "axios"; import { Center, Heading, Table, Thead, Tbody, Tr, Th, Td, } from "@chakra-ui/react"; import { Link } from "react-router-dom"; const Statistic = ({ type, name, players }) => { const ranking = useQuery( `statistic ${type} ${name}`, async () => { const { data } = await axios.get(`/api/statistics/${type}/${name}`); return data; }, { placeholderData: [], } ); const playerDict = useMemo(() => { return Object.assign({}, ...players.data.map((x) => ({ [x.id]: x.name }))); }, [players]); return ( <>
📈
Stonks for {type} {name} {ranking.data.map((x, i) => { return ( ); })}
Player Rank Value
{playerDict[x.playerId]} {x.rank} {x.value}
); }; export default Statistic;