import { useTranslation } from "next-i18next";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const { data: torrentData, error: torrentError } = useWidgetAPI(widget, "torrents");
if (torrentError || !torrentData?.torrents) {
return ;
}
if (!torrentData || !torrentData.torrents) {
return (
);
}
let rateDl = 0;
let rateUl = 0;
let completed = 0;
let leech = 0;
Object.values(torrentData.torrents).forEach(torrent => {
rateDl += torrent.downRate;
rateUl += torrent.upRate;
if(torrent.status.includes('complete')){
completed += 1;
}
if(torrent.status.includes('downloading')){
leech += 1;
}
})
return (
);
}