Files
supabase/apps/studio/data/oauth/oauth-apps-query.ts
Joshen Lim 7f5865872a Enforce noUnusedLocals and noUnusedParameters in tsconfig.json + fix all related issues (#45264)
## Context

Enforce `noUnusedLocals` and `noUnusedParameters` in tsconfig.json + fix
all related issues
2026-04-27 17:42:34 +08:00

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,
})