mirror of
https://github.com/supabase/supabase.git
synced 2026-07-03 06:14:29 +08: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>
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
|
|
import { toast } from 'sonner'
|
|
|
|
import { del, handleError } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { projectKeys } from './keys'
|
|
import { organizationKeys } from 'data/organizations/keys'
|
|
|
|
export type ProjectDeleteVariables = {
|
|
projectRef: string
|
|
organizationSlug?: string
|
|
}
|
|
|
|
export async function deleteProject({ projectRef }: ProjectDeleteVariables) {
|
|
const { data, error } = await del('/platform/projects/{ref}', {
|
|
params: { path: { ref: projectRef } },
|
|
})
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
type ProjectDeleteData = Awaited<ReturnType<typeof deleteProject>>
|
|
|
|
export const useProjectDeleteMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseMutationOptions<ProjectDeleteData, ResponseError, ProjectDeleteVariables>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation<ProjectDeleteData, ResponseError, ProjectDeleteVariables>(
|
|
(vars) => deleteProject(vars),
|
|
{
|
|
async onSuccess(data, variables, context) {
|
|
await queryClient.invalidateQueries(projectKeys.list())
|
|
|
|
if (variables.organizationSlug) {
|
|
queryClient.invalidateQueries(
|
|
organizationKeys.freeProjectLimitCheck(variables.organizationSlug)
|
|
)
|
|
}
|
|
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to delete project: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
}
|
|
)
|
|
}
|