import { useState } from "react" import { useTranslation } from "react-i18next" import { useNavigate } from "@tanstack/react-router" import { CrownIcon, LoaderCircleIcon, LogInIcon, UploadCloudIcon } from "lucide-react" import { AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog" import { Button } from "@/components/ui/button" import { openURL } from "@/utils/dataSender" import { UserPlanLevel, type IPicGoCloudUserInfo } from "#/types/cloud" const PICGO_CLOUD_PRICING_URL = 'https://cloud.picgo.app/pricing' type CloudEmptyStateProps = { userInfo: IPicGoCloudUserInfo | null | undefined cloudTotal: number cloudLoading: boolean onStartImport: () => Promise | void } function isPaidUser (userInfo: IPicGoCloudUserInfo | null | undefined): boolean { return (userInfo?.plan ?? UserPlanLevel.Free) > UserPlanLevel.Free } function ImportButton ({ onStartImport, needsConfirm }: { onStartImport: () => Promise | void, needsConfirm: boolean }) { const { t } = useTranslation() const [open, setOpen] = useState(false) const [loading, setLoading] = useState(false) const handleImport = async () => { setLoading(true) try { await onStartImport() } finally { setLoading(false) setOpen(false) } } if (!needsConfirm) { return ( ) } return ( {t("ALBUM_CLOUD_IMPORT_CONFIRM_TITLE")} {t("ALBUM_CLOUD_IMPORT_CONFIRM_DESC")} {t("CANCEL")} ) } export function CloudEmptyState ({ userInfo, cloudTotal, cloudLoading, onStartImport, }: CloudEmptyStateProps) { const { t } = useTranslation() const navigate = useNavigate() const goToCloudTab = () => { navigate({ to: '/main/cloud' }) } // Not logged in if (userInfo === null || userInfo === undefined) { return (

{t("ALBUM_CLOUD_LOGIN_REQUIRED_TITLE")}

{t("ALBUM_CLOUD_LOGIN_REQUIRED_DESC")}

) } // Free user if (!isPaidUser(userInfo)) { return (

{t("ALBUM_CLOUD_UPGRADE_TITLE")}

{t("ALBUM_CLOUD_UPGRADE_DESC")}

) } // Paid user, empty album if (cloudTotal === 0 && !cloudLoading) { return (

{t("ALBUM_CLOUD_IMPORT_GUIDE_TITLE")}

{t("ALBUM_CLOUD_IMPORT_GUIDE_DESC")}

) } return null }