import React, { CSSProperties, useEffect, useMemo } from "react"; import Spinner from "../../icons/Spinner"; import Logo from "@/components/icons/Logo"; import { useAtomValue } from "jotai"; import { translationAtom } from "@/atoms/translations-atom"; function ProgressBar({ progress, doubleUpscaylCounter, stopHandler, batchMode, }: { progress: string; doubleUpscaylCounter: number; stopHandler: () => void; batchMode: boolean; }) { const [batchProgress, setBatchProgress] = React.useState(0); const t = useAtomValue(translationAtom); useEffect(() => { const progressString = progress.trim().replace(/\n/g, ""); // Remove trailing and leading spaces if (progressString.includes("Successful")) { setBatchProgress((prev) => prev + 1); } }, [progress]); // const progressStyle = useMemo(() => { // if (progress.includes("%")) { // return { // "--value": parseFloat(progress.replace("%", "")), // }; // } else if (progress.includes("Success")) { // return { // "--value": 100, // }; // } // return { // "--value": 0, // }; // }, [progress]); return (
{batchMode && `${t("APP.PROGRESS_BAR.BATCH_UPSCAYL_IN_PROGRESS_TITLE")} ${batchProgress}`}
{progress} {!batchMode && doubleUpscaylCounter > 0 && "\nPass " + doubleUpscaylCounter}
) : ({progress}
)}{t("APP.PROGRESS_BAR.IN_PROGRESS_TITLE")}