import { useQueryClient } from '@tanstack/react-query' import { useParams } from 'common' import { Badge, IconCircle, IconLoader } from 'ui' import { invalidateProjectDetailsQuery } from 'data/projects/project-detail-query' import { useProjectStatusQuery } from 'data/projects/project-status-query' import { invalidateProjectsQuery } from 'data/projects/projects-query' import { PROJECT_STATUS } from 'lib/constants' import { useEffect, useState } from 'react' import { Project } from 'types' export interface PausingStateProps { project: Project } const PausingState = ({ project }: PausingStateProps) => { const { ref } = useParams() const queryClient = useQueryClient() const [startPolling, setStartPolling] = useState(false) useProjectStatusQuery( { projectRef: ref }, { enabled: startPolling, refetchInterval: (res) => { return res?.status === PROJECT_STATUS.INACTIVE ? false : 2000 }, onSuccess: async (res) => { if (res.status === PROJECT_STATUS.INACTIVE) { if (ref) await invalidateProjectDetailsQuery(queryClient, ref) await invalidateProjectsQuery(queryClient) } }, } ) useEffect(() => { setTimeout(() => setStartPolling(true), 4000) }, []) return (
Pausing {project.name}
You may restore your project anytime thereafter, and your data will be restored to when it was initially paused.