♻️ Update DeleteConfirmation component to use new service (#1224)

This commit is contained in:
Alejandra
2024-06-05 12:25:47 -05:00
committed by GitHub
parent 0b16db4fe0
commit ef76179f9f

View File

@@ -11,7 +11,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"
import React from "react"
import { useForm } from "react-hook-form"
import { type ApiError, type UserPublic, UsersService } from "../../client"
import { UsersService, type ApiError } from "../../client"
import useAuth from "../../hooks/useAuth"
import useCustomToast from "../../hooks/useCustomToast"
@@ -28,11 +28,10 @@ const DeleteConfirmation = ({ isOpen, onClose }: DeleteProps) => {
handleSubmit,
formState: { isSubmitting },
} = useForm()
const currentUser = queryClient.getQueryData<UserPublic>(["currentUser"])
const { logout } = useAuth()
const mutation = useMutation({
mutationFn: (id: number) => UsersService.deleteUser({ userId: id }),
mutationFn: () => UsersService.deleteUserMe(),
onSuccess: () => {
showToast(
"Success",
@@ -52,7 +51,7 @@ const DeleteConfirmation = ({ isOpen, onClose }: DeleteProps) => {
})
const onSubmit = async () => {
mutation.mutate(currentUser!.id)
mutation.mutate()
}
return (