import { Box, Flex } from "@chakra-ui/react"; import { t } from "@lingui/macro"; import { Ability } from "@prisma/client"; import AbilityIcon from "components/common/AbilityIcon"; import { mainOnlyAbilities } from "lib/lists/abilities"; import { useMyTheme } from "lib/useMyTheme"; interface ViewAPProps { aps: Record; } const ViewAP: React.FC = ({ aps }) => { const { gray } = useMyTheme(); const APArrays = Object.entries(aps).reduce( (acc: [number, string[]][], [key, value]) => { const apCount = mainOnlyAbilities.includes(key as any) ? 999 : value; const abilityArray = acc.find((el) => el[0] === apCount); if (abilityArray) abilityArray[1].push(key); else acc.push([apCount, [key]]); return acc; }, [] ); let indexToPrintAPAt = APArrays[0][0] === 999 ? 1 : 0; return ( {APArrays.sort((a, b) => b[0] - a[0]).map((arr, index) => { return ( {arr[0] !== 999 ? ( {arr[0]} {indexToPrintAPAt === index ? ( <>
{t`AP`} ) : null}
) : ( )} {(arr[1] as Array).map((ability, abilityIndex) => ( 5 ? `-${(arr[1].length - 5) * 5}px` : undefined } > {/* TODO: center */} ))}
); })}
); }; export default ViewAP;