Files
supabase/apps/studio/data/partners/stripe-projects-query.ts
Alex Hall 99f4b4230a feat: detect integration install state based on partner callbacks (#46488)
Adds support for the new `integration_status` installation
identification method for OAuth marketplace integrations, which will use
the new integration state stored in Marketplace DB and updated via
partner callbacks. Fixes INT-123
2026-06-02 09:46:04 -04:00

38 lines
1.0 KiB
TypeScript

import { queryOptions } from '@tanstack/react-query'
import type { components } from 'api-types'
import { partnersKeys } from './keys'
import { get, handleError } from '@/data/fetchers'
type GetAccountRequestVariables = {
arId?: string
}
export type AccountRequestDetails = components['schemas']['AccountRequestDetailsDto']
async function getAccountRequest({ arId }: GetAccountRequestVariables, signal?: AbortSignal) {
if (!arId) throw new Error('Account request ID is required')
const { data, error } = await get(
'/platform/stripe/projects/provisioning/account_requests/{id}',
{
params: { path: { id: arId } },
signal,
}
)
if (error) handleError(error)
return data
}
export const accountRequestQueryOptions = (
{ arId }: GetAccountRequestVariables,
{ enabled = true }: { enabled?: boolean } = { enabled: true }
) => {
return queryOptions({
queryKey: partnersKeys.getStripeProjects(arId),
queryFn: ({ signal }) => getAccountRequest({ arId }, signal),
enabled: enabled && typeof arId !== 'undefined',
})
}