Files
supabase/apps/studio/data/platform-apps/platform-apps-query.ts
T
kemal.earth a9a1326b92 feat(studio): private apps ui (#43382)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

This is a prototype for private apps UI. There are no endpoints at the
minute, just wanted to see what a potential flow could look like.
2026-03-23 10:51:04 -06:00

42 lines
1.3 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import type { components } from 'api-types'
import { get, handleError } from 'data/fetchers'
import type { ResponseError, UseCustomQueryOptions } from 'types'
import { platformAppKeys } from './keys'
export type PlatformAppsVariables = {
slug?: string
}
export type PlatformApp = components['schemas']['ListPlatformAppsResponse']['apps'][number]
export async function getPlatformApps({ slug }: PlatformAppsVariables, signal?: AbortSignal) {
if (!slug) throw new Error('slug is required')
const { data, error } = await get('/platform/organizations/{slug}/apps', {
params: { path: { slug } },
signal,
})
if (error) handleError(error)
return data
}
export type PlatformAppsData = Awaited<ReturnType<typeof getPlatformApps>>
export type PlatformAppsError = ResponseError
export const usePlatformAppsQuery = <TData = PlatformAppsData>(
{ slug }: PlatformAppsVariables,
{
enabled = true,
...options
}: UseCustomQueryOptions<PlatformAppsData, PlatformAppsError, TData> = {}
) =>
useQuery<PlatformAppsData, PlatformAppsError, TData>({
queryKey: platformAppKeys.list(slug),
queryFn: ({ signal }) => getPlatformApps({ slug }, signal),
enabled: enabled && typeof slug !== 'undefined',
...options,
})