/* * Copyright (C) Contributors to the Suwayomi project * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { CircularProgress, Box } from '@mui/material'; import Typography from '@mui/material/Typography'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { IDownloadChapter, TranslationKey } from 'typings'; interface DownloadStateIndicatorProps { download: IDownloadChapter; } const DOWNLOAD_STATE_TO_TRANSLATION_KEY_MAP: { [state in IDownloadChapter['state']]: TranslationKey } = { Downloading: 'download.state.label.downloading', Error: 'download.state.label.error', Finished: 'download.state.label.finished', Queued: 'download.state.label.queued', } as const; const DownloadStateIndicator: React.FC = ({ download }) => { const { t } = useTranslation(); return ( {download.progress !== 0 && } <> {download.progress !== 0 && `${Math.round(download.progress * 100)}%`} {download.progress === 0 && t(DOWNLOAD_STATE_TO_TRANSLATION_KEY_MAP[download.state])} ); }; export default DownloadStateIndicator;