diff --git a/frontend/src/pages/FileView.tsx b/frontend/src/pages/FileView.tsx index 1e1a58e..ab69735 100644 --- a/frontend/src/pages/FileView.tsx +++ b/frontend/src/pages/FileView.tsx @@ -11,6 +11,9 @@ const FileView = (): JSX.Element => { const { downloadInfo, error, isLoading } = useDownloadInfo(uploadId) const remainingDownloads = useMemo(() => { if (!downloadInfo) return undefined + if (downloadInfo.metadata.maxDownloads === -1) { + return Infinity + } return downloadInfo.metadata.maxDownloads - downloadInfo.metadata.currentDownloads }, [downloadInfo]) @@ -29,20 +32,38 @@ const FileView = (): JSX.Element => { return `/api/upload/${uploadId}/archive` } + + const getDownloadInfoString = () : string => { + if(isLoading || error){ + return "" + } + if(remainingDownloads === Infinity){ + return "You can download this file infinitely often" + } + return `You can download this file ${remainingDownloads} more time${(remainingDownloads ?? 0) > 1 && "s"}` + } + + const getExpirationString = () : string => { + if (downloadInfo?.metadata.expires === -1 ){ + return "This upload will never expire" + } + return `This upload will expire on ${expiration}` + } + return (
- Download File{remainingDownloads !== 1 && "s"} + Download File{(downloadInfo?.files.length ?? 0) > 1 && "s"} {isLoading && } {!isLoading && !error && !!remainingDownloads &&

- You can download this file {remainingDownloads} more time{remainingDownloads !== 1 && "s"} + {getDownloadInfoString()}

}
@@ -77,7 +98,7 @@ const FileView = (): JSX.Element => { )} {!isLoading && !error &&
-

This upload will expire on {expiration}

+

{getExpirationString()}

}