mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
* fix(studio): add refetch after github pop-up close * fix: github.ts * fix: add delay * chore: increase to 2s * chore: remove debug logs
32 lines
1.1 KiB
TypeScript
32 lines
1.1 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 async function getGitHubRepositories(signal?: AbortSignal) {
|
|
const { data, error } = await get('/platform/integrations/github/repositories', {
|
|
signal,
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data.repositories
|
|
}
|
|
|
|
export type GitHubRepositoriesData = Awaited<ReturnType<typeof getGitHubRepositories>>
|
|
export type ProjectGitHubRepositoryConnectionsData = Awaited<
|
|
ReturnType<typeof getGitHubRepositories>
|
|
>
|
|
export type GitHubRepositoriesError = ResponseError
|
|
|
|
export const useGitHubRepositoriesQuery = <TData = GitHubRepositoriesData>({
|
|
enabled = true,
|
|
...options
|
|
}: UseQueryOptions<GitHubRepositoriesData, GitHubRepositoriesError, TData> = {}) => {
|
|
return useQuery<GitHubRepositoriesData, GitHubRepositoriesError, TData>(
|
|
integrationKeys.githubRepositoriesList(),
|
|
({ signal }) => getGitHubRepositories(signal),
|
|
{ enabled, staleTime: 0, ...options }
|
|
)
|
|
}
|