mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 18:11:51 +08:00
## Context Enforce `noUnusedLocals` and `noUnusedParameters` in tsconfig.json + fix all related issues
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { components } from 'api-types'
|
|
|
|
import { oauthAppKeys } from './keys'
|
|
import { get, handleError } from '@/data/fetchers'
|
|
import type { ResponseError, UseCustomQueryOptions } from '@/types'
|
|
|
|
export type OAuthAppsVariables = {
|
|
slug?: string
|
|
}
|
|
|
|
export type OAuthApp = components['schemas']['OAuthAppResponse']
|
|
|
|
export async function getOAuthApps({ slug }: OAuthAppsVariables) {
|
|
if (!slug) throw new Error('Organization slug is required')
|
|
|
|
const { data, error } = await get('/platform/organizations/{slug}/oauth/apps', {
|
|
params: { path: { slug }, query: { type: 'published' } },
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type OAuthAppsData = Awaited<ReturnType<typeof getOAuthApps>>
|
|
export type OAuthAppsError = ResponseError
|
|
|
|
export const useOAuthAppsQuery = <TData = OAuthAppsData>(
|
|
{ slug }: OAuthAppsVariables,
|
|
{ enabled = true, ...options }: UseCustomQueryOptions<OAuthAppsData, OAuthAppsError, TData> = {}
|
|
) =>
|
|
useQuery<OAuthAppsData, OAuthAppsError, TData>({
|
|
queryKey: oauthAppKeys.oauthApps(slug),
|
|
queryFn: () => getOAuthApps({ slug }),
|
|
enabled: enabled && typeof slug !== 'undefined',
|
|
...options,
|
|
})
|