mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 19:35:06 +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>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import { components } from 'api-types'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import { ResponseError } from 'types'
|
|
import { projectKeys } from './keys'
|
|
|
|
export type CloneStatus = components['schemas']['ProjectClonedStatusResponse']
|
|
|
|
export async function getCloneStatus(projectRef?: string) {
|
|
if (!projectRef) throw new Error('Project ref is required')
|
|
|
|
const { data, error } = await get(`/platform/database/{ref}/clone/status`, {
|
|
params: { path: { ref: projectRef } },
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type CloneStatusData = Awaited<ReturnType<typeof getCloneStatus>>
|
|
export type CloneStatusError = ResponseError
|
|
|
|
export const useCloneStatusQuery = <TData = CloneStatusData>(
|
|
{ projectRef }: { projectRef?: string },
|
|
options: UseQueryOptions<CloneStatusData, CloneStatusError, TData> = {}
|
|
) => {
|
|
return useQuery<CloneStatusData, CloneStatusError, TData>({
|
|
queryKey: projectKeys.listCloneStatus(projectRef),
|
|
queryFn: () => getCloneStatus(projectRef),
|
|
enabled: !!projectRef,
|
|
...options,
|
|
})
|
|
}
|