mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 21:05:06 +03:00
* privatelink integration * mock queries * add integration endpoints * poll for updates on transition states * prevent ui for multiple posts * changes to copy for existing accounts * update privatelink documentation * hide privatelink for customer under Team plan * added connected state tip * linting fixes * fixed issue due to merge * Add cc feature flag * Nit clean up * Small revert * Nudge UI a little * Update react queries to fit new structure * Fix * Clean up * nit * revert padding * Fix * fix: tanstack changes * added feature to pricing page * Update apps/docs/content/guides/platform/privatelink.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: dropdown copy change * Update apps/docs/content/guides/platform/privatelink.mdx Co-authored-by: Chris Chinchilla <chris.ward@supabase.io> * Update apps/docs/content/guides/platform/privatelink.mdx Co-authored-by: Chris Chinchilla <chris.ward@supabase.io> * Smol clean up --------- Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Chris Chinchilla <chris.ward@supabase.io>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
|
|
import { toast } from 'sonner'
|
|
|
|
import { handleError, post } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { awsAccountKeys } from './keys'
|
|
|
|
export type AWSAccountCreateVariables = {
|
|
projectRef: string
|
|
awsAccountId: string
|
|
accountName?: string
|
|
}
|
|
|
|
export async function createAWSAccount({
|
|
projectRef,
|
|
awsAccountId,
|
|
accountName,
|
|
}: AWSAccountCreateVariables) {
|
|
const { data, error } = await post(
|
|
'/platform/projects/{ref}/privatelink/associations/aws-account',
|
|
{
|
|
params: {
|
|
path: { ref: projectRef },
|
|
},
|
|
body: {
|
|
aws_account_id: awsAccountId,
|
|
account_name: accountName,
|
|
},
|
|
}
|
|
)
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
type AWSAccountCreateData = Awaited<ReturnType<typeof createAWSAccount>>
|
|
|
|
export const useAWSAccountCreateMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseMutationOptions<AWSAccountCreateData, ResponseError, AWSAccountCreateVariables>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
return useMutation<AWSAccountCreateData, ResponseError, AWSAccountCreateVariables>({
|
|
mutationFn: (vars) => createAWSAccount(vars),
|
|
async onSuccess(data, variables, context) {
|
|
const { projectRef } = variables
|
|
await queryClient.invalidateQueries({ queryKey: awsAccountKeys.list(projectRef) })
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to create AWS account: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
})
|
|
}
|