import { Alert, Center, Code, Group, Progress, Skeleton, Table, Text, Title, Tooltip, useMantineTheme, } from '@mantine/core'; import { IconAlertCircle, IconPlayerPause, IconPlayerPlay } from '@tabler/icons'; import { AxiosError } from 'axios'; import dayjs from 'dayjs'; import duration from 'dayjs/plugin/duration'; import { FunctionComponent, useState } from 'react'; import { useGetUsenetDownloads } from '../../tools/hooks/api'; import { humanFileSize } from '../../tools/humanFileSize'; dayjs.extend(duration); interface UsenetQueueListProps { serviceId: string; } const PAGE_SIZE = 10; export const UsenetQueueList: FunctionComponent = ({ serviceId }) => { const theme = useMantineTheme(); const [page, setPage] = useState(1); const { data, isLoading, isError, error } = useGetUsenetDownloads({ limit: PAGE_SIZE, offset: (page - 1) * PAGE_SIZE, serviceId, }); if (isLoading) { return ( <> ); } if (isError) { return ( } my="lg" title="Error!" color="red" radius="md"> Some error has occured while fetching data: {(error as AxiosError)?.response?.data as string} ); } if (!data || data.items.length <= 0) { return (
Queue is empty
); } return ( {data.items.map((nzb) => ( ))}
Name Size ETA Progress
{nzb.state === 'paused' ? ( ) : ( )} {nzb.name} {humanFileSize(nzb.size)} {nzb.eta <= 0 ? ( Paused ) : ( {dayjs.duration(nzb.eta, 's').format('H:mm:ss')} )} {nzb.progress.toFixed(1)}% 0 ? theme.primaryColor : 'lightgrey'} value={nzb.progress} size="lg" style={{ width: '100%' }} />
); };