/* eslint-disable @next/next/no-img-element */ import { NormalizedTorrent } from '@ctrl/shared-torrent'; import { Badge, Flex, Group, List, MantineColor, Progress, Stack, Text, createStyles, useMantineTheme } from '@mantine/core'; import { IconAffiliate, IconDatabase, IconDownload, IconFileInfo, IconInfoCircle, IconPercentage, IconSortDescending, IconUpload, } from '@tabler/icons-react'; import { useTranslation } from 'next-i18next'; import { humanFileSize } from '~/tools/humanFileSize'; import { AppType } from '~/types/app'; interface TorrentQueueItemProps { torrent: NormalizedTorrent; app?: AppType; width: number; } export const TorrentQueuePopover = ({ torrent, app }: Omit) => { const { t } = useTranslation('modules/torrents-status'); const { colors } = useMantineTheme(); const RatioMetric = () => { const color = (): MantineColor => { if (torrent.ratio < 1) { return colors.red[7]; } if (torrent.ratio < 1.15) { return colors.orange[7]; } return colors.green[7]; }; return ( {t('card.popover.metrics.ratio')} {torrent.ratio.toFixed(2)} ); }; return ( {app && ( {t('card.popover.introductionPrefix')} download client logo {app.name} )} }> {torrent.name} }> }> {t('card.popover.metrics.queuePosition', { position: torrent.queuePosition })} }> {t('card.popover.metrics.progress', { progress: (torrent.progress * 100).toFixed(2), })} }> {t('card.popover.metrics.totalSelectedSize', { totalSize: humanFileSize(torrent.totalSelected, false), })} }> {humanFileSize(torrent.totalDownloaded, false)} {humanFileSize(torrent.totalUploaded, false)} }> {t('card.popover.metrics.state', { state: torrent.stateMessage !== '' ? torrent.stateMessage : torrent.state, })} {torrent.label && {torrent.label}} {torrent.isCompleted && ( {t('card.popover.metrics.completed')} )} ); }; const useStyles = createStyles(() => ({ noTextBreak: { whiteSpace: 'nowrap', }, }));