import { useParams } from 'common' import dayjs from 'dayjs' import { PauseCircle } from 'lucide-react' import Link from 'next/link' import { Button, Card, CardContent, CardFooter, cn, Tooltip, TooltipContent, TooltipTrigger, } from 'ui' import { TimestampInfo } from 'ui-patterns' import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' import { PauseDisabledState } from './PauseDisabledState' import { ResumeProjectButton } from '@/components/interfaces/Project/ResumeProjectButton' import { AlertError } from '@/components/ui/AlertError' import { InlineLinkClassName } from '@/components/ui/InlineLink' 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 }) const finalDaysRemainingBeforeRestoreDisabled = pauseStatus?.remaining_days_till_restore_disabled ?? pauseStatus?.max_days_till_restore_disabled ?? 0 const isFreePlan = selectedOrganization?.plan?.id === 'free' const isRestoreDisabled = isPauseStatusSuccess && !pauseStatus.can_restore return (

The project "{project?.name}" is currently paused

{isLoading && } {isPauseStatusSuccess && !isRestoreDisabled ? ( isFreePlan ? ( <>

All data, including backups and storage objects, remains safe. You can resume this project from the dashboard within{' '} {finalDaysRemainingBeforeRestoreDisabled} day {finalDaysRemainingBeforeRestoreDisabled > 1 ? 's' : ''} {' '} Free projects cannot be restored through the dashboard if they are paused for more than {pauseStatus.max_days_till_restore_disabled} days {' '} (until{' '} ). After that, this project will not be resumable, but data will still be available for download.

{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 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 && }
) }