import React, { useEffect, ReactElement } from "react"; import { getDownloadProgress } from "../actions/airdcpp.actions"; import { useDispatch, useSelector } from "react-redux"; import { RootState } from "threetwo-ui-typings"; import { isNil } from "lodash"; import prettyBytes from "pretty-bytes"; interface IDownloadsPanelProps { data: any; } export const DownloadsPanel = ( props: IDownloadsPanelProps, ): ReactElement | null => { const downloadProgressTick = useSelector( (state: RootState) => state.airdcpp.downloadProgressData, ); const dispatch = useDispatch(); useEffect(() => { dispatch(getDownloadProgress("12312")); }, [dispatch]); return !isNil(downloadProgressTick) ? (
{JSON.stringify(downloadProgressTick)} {(parseInt(downloadProgressTick.downloaded_bytes) / parseInt(downloadProgressTick.size)) * 100} %
{downloadProgressTick.name}
{prettyBytes(downloadProgressTick.downloaded_bytes)} of {prettyBytes(downloadProgressTick.size)}
{prettyBytes(downloadProgressTick.speed)} per second. Time left: {parseInt(downloadProgressTick.seconds_left) / 60}
{downloadProgressTick.target}
) : null; }; export default DownloadsPanel;