import { useQuery } from '@tanstack/react-query' import { projectKeys } from './keys' import { get, handleError } from '@/data/fetchers' import type { ResponseError, UseCustomQueryOptions } from '@/types' export type ProjectPauseStatusVariables = { ref?: string } export async function getProjectPausedStatus( { ref }: ProjectPauseStatusVariables, signal?: AbortSignal ) { if (!ref) throw new Error('Project ref is required') const { data, error } = await get('/platform/projects/{ref}/pause/status', { params: { path: { ref } }, signal, }) if (error) handleError(error) return data } export type ProjectPauseStatusData = Awaited> export type ProjectPauseStatusError = ResponseError export const useProjectPauseStatusQuery = ( { ref }: ProjectPauseStatusVariables, { enabled = true, ...options }: UseCustomQueryOptions = {} ) => useQuery({ queryKey: projectKeys.pauseStatus(ref), queryFn: ({ signal }) => getProjectPausedStatus({ ref }, signal), enabled: enabled && typeof ref !== 'undefined', ...options, })