import { Product } from "@/_models/Product"; import DownloadModelContent from "../DownloadModelContent"; import ModelDownloadButton from "../ModelDownloadButton"; import ModelDownloadingButton from "../ModelDownloadingButton"; import { useAtomValue } from "jotai"; import { modelDownloadStateAtom } from "@/_helpers/atoms/DownloadState.atom"; type Props = { product: Product; isRecommend: boolean; required?: string; onDownloadClick?: (product: Product) => void; }; const AvailableModelCard: React.FC = ({ product, isRecommend, required, onDownloadClick, }) => { const downloadState = useAtomValue(modelDownloadStateAtom); let isDownloading = false; let total = 0; let transferred = 0; if (product.fileName && downloadState[product.fileName]) { isDownloading = downloadState[product.fileName].error == null && downloadState[product.fileName].percent < 1; if (isDownloading) { total = downloadState[product.fileName].size.total; transferred = downloadState[product.fileName].size.transferred; } } const downloadButton = isDownloading ? (
) : (
onDownloadClick?.(product)} />
); return (
{downloadButton}
{/* */}
); }; export default AvailableModelCard;