import { Link } from '@tanstack/react-router' import { useParams } from 'common' import dayjs from 'dayjs' import { PauseCircleIcon } from 'lucide-react' import { Button, Card, CardContent, CardFooter } from 'ui' import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' import { TimestampInfo } from 'ui-patterns/TimestampInfo' import { DownloadBackupsSection } from './DownloadBackupsSection' import { PauseDisabledState } from './PauseDisabledState' import { ResumeProjectButton } from '@/components/interfaces/Project/ResumeProjectButton' import { AlertError } from '@/components/ui/AlertError' import { UpgradePlanButton } from '@/components/ui/UpgradePlanButton' import { useProjectPauseStatusQuery } from '@/data/projects/project-pause-status-query' import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' import { usePHFlag } from '@/hooks/ui/useFlag' import { PROJECT_STATUS } from '@/lib/constants' export interface ProjectPausedStateProps { product?: string } export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => { const { ref } = useParams() const { data: project } = useSelectedProjectQuery() const { data: selectedOrganization } = useSelectedOrganizationQuery() const enableProBenefitWording = usePHFlag('proBenefitWording') const { data: pauseStatus, error: pauseStatusError, isError, isSuccess: isPauseStatusSuccess, isPending: isLoading, } = useProjectPauseStatusQuery({ ref }, { enabled: project?.status === PROJECT_STATUS.INACTIVE }) // null when there is no expiry (e.g. paid plans can always restore) const restoreExpiresAt = pauseStatus?.remaining_days_till_restore_disabled != null ? dayjs().utc().add(pauseStatus.remaining_days_till_restore_disabled, 'day').toISOString() : null const isFreePlan = selectedOrganization?.plan?.id === 'free' const isRestoreDisabled = isPauseStatusSuccess && !pauseStatus.can_restore return (

Project "{project?.name}" is paused

{isLoading && } {isPauseStatusSuccess && !isRestoreDisabled ? ( isFreePlan ? (
  • All data, including backups and storage objects, remains safe.
  • {restoreExpiresAt ? ( <>
  • You can resume this project from the dashboard until{' '} .
  • After that, this project will not be resumable, but data will still be available for download.
  • ) : (
  • You can resume this project from the dashboard.
  • )}
  • {enableProBenefitWording === 'variant-a' ? 'Upgrade to Pro to prevent pauses and unlock features like branching, compute upgrades, and daily backups.' : 'To prevent future pauses, consider upgrading to Pro.'}
) : ( <>

Your project data is safe {restoreExpiresAt ? ( <> {' '} and available until{' '} ) : null} , but inaccessible while paused.

Once resumed, usage will be billed by compute size and hours active.

) ) : !isLoading ? (

All of your project's data is still intact, but your project is inaccessible while paused.{' '} {product !== undefined ? ( <> Resume this project to access the{' '} {product} page. ) : !isRestoreDisabled ? ( Resume this project and get back to building! ) : null}

) : null}
{isError && ( )} {isPauseStatusSuccess && !isRestoreDisabled && ( <> {isFreePlan ? ( ) : ( )} )} {isPauseStatusSuccess && isRestoreDisabled && }
) }