mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 16:19:10 +03:00
* RQ convert mutateAsync calls to mutate where possible, otherwise add try finally blocks * Skip eligibility query if project status is coming up * Small UI update to replicas side panel * Update apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx Co-authored-by: Alaister Young <alaister@users.noreply.github.com> * Add error handling in CIDR * Prettier lint --------- Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
|
|
import toast from 'react-hot-toast'
|
|
|
|
import { delete_ } from 'lib/common/fetch'
|
|
import { API_URL } from 'lib/constants'
|
|
import type { ResponseError } from 'types'
|
|
|
|
export type UserDeleteMFAFactorsVariables = {
|
|
projectRef: string
|
|
userId: string
|
|
}
|
|
|
|
export async function deleteMFAFactors({ projectRef, userId }: UserDeleteMFAFactorsVariables) {
|
|
const response = await delete_(`${API_URL}/auth/${projectRef}/users/${userId}/factors`)
|
|
if (response.error) throw response.error
|
|
return response
|
|
}
|
|
|
|
type UserDeleteMFAFactorsData = Awaited<ReturnType<typeof deleteMFAFactors>>
|
|
|
|
export const useUserDeleteMFAFactorsMutation = ({
|
|
onSuccess,
|
|
onError,
|
|
...options
|
|
}: Omit<
|
|
UseMutationOptions<UserDeleteMFAFactorsData, ResponseError, UserDeleteMFAFactorsVariables>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
return useMutation<UserDeleteMFAFactorsData, ResponseError, UserDeleteMFAFactorsVariables>(
|
|
(vars) => deleteMFAFactors(vars),
|
|
{
|
|
async onSuccess(data, variables, context) {
|
|
// [Joshen] If we need to invalidate any queries
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to delete the user's MFA factors: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
}
|
|
)
|
|
}
|