import { EightK, FourK, Hd, Sd } from "@mui/icons-material"; import { Button, Card, CardActionArea, CardActions, CardContent, CardMedia, Chip, LinearProgress, Skeleton, Stack, Typography } from "@mui/material"; import { useEffect, useState } from "react"; import { ellipsis, formatSpeedMiB, roundMiB } from "../utils"; type Props = { title: string, thumbnail: string, resolution: string percentage: string, size: number, speed: number, stopCallback: VoidFunction, } export function StackableResult({ title, thumbnail, resolution, percentage, speed, size, stopCallback }: Props) { const [isCompleted, setIsCompleted] = useState(false) useEffect(() => { if (percentage === '-1') { setIsCompleted(true) } }, [percentage]) const percentageToNumber = () => isCompleted ? 100 : Number(percentage.replace('%', '')) const guessResolution = (xByY: string): any => { if (!xByY) return null; if (xByY.includes('4320')) return (); if (xByY.includes('2160')) return (); if (xByY.includes('1080')) return (); if (xByY.includes('720')) return (); return null; } return ( {thumbnail !== '' ? : } {title !== '' ? {ellipsis(title, 54)} : } {!isCompleted ? percentage : ''} {!isCompleted ? formatSpeedMiB(speed) : ''} {roundMiB(size ?? 0)} {guessResolution(resolution)} {percentage ? : null } ) }