mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 02:45:07 +03:00
* chore(studio): swap react-query to object syntax * Fix small issues found * Fix realtime settings * Nit --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
31 lines
1011 B
TypeScript
31 lines
1011 B
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import { get, handleError } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { integrationKeys } from './keys'
|
|
|
|
export async function getIntegrations(signal?: AbortSignal) {
|
|
const { data, error } = await get('/platform/integrations', {
|
|
signal,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type IntegrationsData = Awaited<ReturnType<typeof getIntegrations>>
|
|
export type ProjectIntegrationConnectionsData = Awaited<ReturnType<typeof getIntegrations>>
|
|
export type IntegrationsError = ResponseError
|
|
|
|
export const useIntegrationsQuery = <TData = IntegrationsData>({
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<IntegrationsData, IntegrationsError, TData> = {}) =>
|
|
useQuery<IntegrationsData, IntegrationsError, TData>({
|
|
queryKey: integrationKeys.integrationsList(),
|
|
queryFn: ({ signal }) => getIntegrations(signal),
|
|
enabled: enabled,
|
|
staleTime: 30 * 60 * 1000,
|
|
...options,
|
|
})
|