import { MinusCircledIcon, TriangleDownIcon, TriangleUpIcon, } from "@radix-ui/react-icons"; import { Checkbox, Flex, IconButton, Table, Text } from "@radix-ui/themes"; import { memo } from "react"; import { api } from "../api/dynamic"; import { useLocale } from "../hooks/useLocale"; import { Playlist, type PlaylistEntry } from "../stores/playlist"; import { TankRowHeaderCell } from "./TankRowHeaderCell"; interface Props extends PlaylistEntry { index: number; } const tankDefinitions = await api.tanks(); export const PlaylistTankEntry = memo( ({ id, checked, then, now, index }) => { const { locale, strings } = useLocale(); const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" }); const dateNow = Date.now(); const tank = tankDefinitions.tanks[id]; return ( {index + 1} { Playlist.mutate((draft) => { draft.list![index].checked = !checked; }); }} > then.battles) || checked } /> { Playlist.mutate((draft) => { draft.list!.splice(index, 1); }); }} > {now && then && now.battles !== then.battles ? ( {now.wins - then.wins} {now.battles - then.battles - now.wins + then.wins} ) : ( strings.website.tools.playlist.table.unrecorded )} {now?.battles ?? strings.website.tools.playlist.table.unrecorded} {now && now.last !== 0 ? rtf.format( Math.ceil((now.last - dateNow / 1000) / (60 * 60 * 24)), "day", ) : strings.website.tools.playlist.table.unrecorded} ); }, (a, b) => a.checked === b.checked && a.then?.battles === b.then?.battles && a.index === b.index, );