mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 07:39:07 +03:00
* add main log drain form and navigation * fix submit and select * add mutation and update form * fix submit issue * fix issues with validation * fix typeerrs * add log drain table * update create log drain mutation * add delete log drain mutation * update get log drains query * fix new log drain click in cards * add delete mutation * add delete log drain * refactor gzip switch * refactor radiogroup to use formfield * add headers form * fix validation, custom headers errors * refactor to support update in form * format * add log drains to nav * update api spec and list logdrains query * wire backend * fix datadog region values * make api input password * fix url elastic * fix typerr * rm unnecessary value setter * fix state issue log drains update form * Add default values setting in useEffect to fix form issues * format * Update LogDrains table header width to 250px * add upgrade plan card when free plan * fix dumb if statement * fix the freaking headers * fix upgrade to team state * fix plan check and loading state * disable type update * Add link to documentation in Log Drains settings * show add destination only after empty state * fix bug with inputs not resetting * add gzip tooltip * rm command * defaultValue to value * add defaultValue * rm consolelog * rm anys
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { logDrainsKeys } from './keys'
|
|
import { ResponseError } from 'types'
|
|
|
|
export type LogDrainsVariables = {
|
|
ref?: string
|
|
}
|
|
|
|
export async function getLogDrains({ ref }: LogDrainsVariables, signal?: AbortSignal) {
|
|
if (!ref) {
|
|
throw new Error('ref is required')
|
|
}
|
|
|
|
const { data, error } = await get(`/platform/projects/{ref}/analytics/log-drains`, {
|
|
params: { path: { ref: ref } },
|
|
signal,
|
|
})
|
|
|
|
if (error) {
|
|
handleError(error)
|
|
}
|
|
|
|
return data
|
|
}
|
|
|
|
export type LogDrainsData = Awaited<ReturnType<typeof getLogDrains>>
|
|
export type LogDrainData = LogDrainsData[number]
|
|
export type LogDrainsyError = ResponseError
|
|
|
|
export const useLogDrainsQuery = <TData = LogDrainsData>(
|
|
{ ref }: LogDrainsVariables,
|
|
{ enabled, ...options }: UseQueryOptions<LogDrainsData, LogDrainsyError, TData> = {}
|
|
) =>
|
|
useQuery<LogDrainsData, LogDrainsyError, TData>(
|
|
logDrainsKeys.list(ref),
|
|
({ signal }) => getLogDrains({ ref }, signal),
|
|
{
|
|
enabled: enabled && !!ref,
|
|
refetchOnMount: false,
|
|
...options,
|
|
}
|
|
)
|