import React from "react";
import { useQuery } from "react-query";
import axios from "axios";
import {
Center,
Heading,
Image,
Table,
Thead,
Tbody,
Tr,
Th,
Td,
} from "@chakra-ui/react";
import { Link } from "react-router-dom";
import prettifyStatisticName from "./PrettifyStatisticName";
const Player = ({ playerId, players }) => {
const playerStats = useQuery(`player ${playerId}`, async () => {
const { data } = await axios.get(`/api/players/${playerId}`);
data.sort((a, b) => a.rank - b.rank || b.value - a.value);
return data.filter((x) => x.value > 0);
});
const playerName = players?.find((x) => x.id === playerId)?.name;
return (
<>
Statistic | Rank | Value |
---|---|---|
{prettifyStatisticName(x.type, x.name)} | {x.rank} | {x.value} |