mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 06:09:08 +03:00
* Add restrictions for orioledb technical preview * Add callouts to pgvector and postgis if orioledb * Restrict restore to new project for orioledb * Scaffold client side validation for preventing org upgrade if org has oriole db present * Hook up proper logic for oriole * Fix * Remove console log * Fix type * Disable version selector if only one version is available * chore: oriole badges * UI updates based on requests * Update copy * Fix * Dont open assistant if opt is selected * Fix * Fix * Update badge * Add feature flag for orioleDB * Feature flag oriole check in plan update --------- Co-authored-by: Paul Cioanca <paul.cioanca@supabase.io>
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { QueryClient, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import { components } from 'api-types'
|
|
import { get, handleError } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { organizationKeys } from './keys'
|
|
|
|
export type OrganizationVariables = { slug?: string }
|
|
export type OrganizationDetail = components['schemas']['OrganizationSlugResponse']
|
|
|
|
function castOrganizationSlugResponseToOrganization(
|
|
org: components['schemas']['OrganizationSlugResponse']
|
|
) {
|
|
return {
|
|
...org,
|
|
billing_email: org.billing_email ?? 'Unknown',
|
|
managed_by: org.slug.startsWith('vercel_icfg_') ? 'vercel-marketplace' : 'supabase',
|
|
partner_id: org.slug.startsWith('vercel_') ? org.slug.replace('vercel_', '') : undefined,
|
|
}
|
|
}
|
|
|
|
export async function getOrganization({ slug }: OrganizationVariables, signal?: AbortSignal) {
|
|
if (!slug) throw new Error('Organization slug is required')
|
|
|
|
const { data, error } = await get('/platform/organizations/{slug}', {
|
|
params: { path: { slug } },
|
|
signal,
|
|
})
|
|
if (error) handleError(error)
|
|
return castOrganizationSlugResponseToOrganization(data)
|
|
}
|
|
|
|
export type OrganizationsData = Awaited<ReturnType<typeof getOrganization>>
|
|
export type OrganizationsError = ResponseError
|
|
|
|
export const useOrganizationQuery = <TData = OrganizationsData>(
|
|
{ slug }: OrganizationVariables,
|
|
{ enabled = true, ...options }: UseQueryOptions<OrganizationsData, OrganizationsError, TData> = {}
|
|
) => {
|
|
return useQuery<OrganizationsData, OrganizationsError, TData>(
|
|
organizationKeys.detail(slug),
|
|
({ signal }) => getOrganization({ slug }, signal),
|
|
{ enabled: enabled && typeof slug !== 'undefined', ...options, staleTime: 30 * 60 * 1000 }
|
|
)
|
|
}
|
|
|
|
export function invalidateOrganizationsQuery(client: QueryClient) {
|
|
return client.invalidateQueries(organizationKeys.list())
|
|
}
|