mirror of
https://github.com/supabase/supabase.git
synced 2026-05-27 14:58:19 +08:00
* feat: show upgrade warning if user objects exist in internal schemas * Clean up warnings into a separate file * Update API types + fix TS issues * Update apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureInfo.tsx --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { integrationKeys } from './keys'
|
|
|
|
export type GitHubBranchesVariables = {
|
|
connectionId?: number
|
|
}
|
|
|
|
export async function getGitHubBranches(
|
|
{ connectionId }: GitHubBranchesVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
if (!connectionId) throw new Error('connectionId is required')
|
|
|
|
const { data, error } = await get(`/platform/integrations/github/branches/{connectionId}`, {
|
|
params: { path: { connectionId } },
|
|
signal,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type GitHubBranchesData = Awaited<ReturnType<typeof getGitHubBranches>>
|
|
export type GitHubBranchesError = ResponseError
|
|
|
|
export const useGitHubBranchesQuery = <TData = GitHubBranchesData>(
|
|
{ connectionId }: GitHubBranchesVariables,
|
|
{
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<GitHubBranchesData, GitHubBranchesError, TData> = {}
|
|
) =>
|
|
useQuery<GitHubBranchesData, GitHubBranchesError, TData>(
|
|
integrationKeys.githubBranchesList(connectionId),
|
|
({ signal }) => getGitHubBranches({ connectionId }, signal),
|
|
{
|
|
enabled: enabled && typeof connectionId !== 'undefined',
|
|
...options,
|
|
}
|
|
)
|