Files
supabase/studio/hooks/queries/useProjectUsageStatus.ts
2022-08-04 12:02:50 +08:00

17 lines
442 B
TypeScript

import useSWR from 'swr'
import { get } from 'lib/common/fetch'
import { API_URL } from 'lib/constants'
export function useProjectUsageStatus(ref: string) {
const url = `${API_URL}/projects/${ref}/usage-status`
const { data, error } = useSWR<any>(url, get)
const anyError = data?.error || error
return {
config: anyError ? undefined : data,
error: anyError,
isLoading: !anyError && !data,
isError: !!anyError,
}
}