import { useState } from "react" import { useTranslation } from "react-i18next" import { XIcon } from "lucide-react" import { Button } from "@/components/ui/button" import { useIPCOn } from "@/hooks/useIPC" import type { CloudImportProgress } from "#/types/cloudAlbum" type CloudImportProgressBannerProps = { onComplete: () => void } export function CloudImportProgressBanner ({ onComplete }: CloudImportProgressBannerProps) { const { t } = useTranslation() const [progress, setProgress] = useState(null) const [dismissed, setDismissed] = useState(false) useIPCOn('CLOUD_IMPORT_PROGRESS', (_event: unknown, data: CloudImportProgress) => { setProgress(data) setDismissed(false) if (data.current >= data.total) { setTimeout(() => { setDismissed(true) onComplete() }, 2000) } }) if (!progress || dismissed) return null const percentage = progress.total > 0 ? Math.round((progress.current / progress.total) * 100) : 0 return (
{t("ALBUM_CLOUD_IMPORTING")} {progress.current}/{progress.total}
) }