Skip to content

Commit

Permalink
♻️ Update DeleteConfirmation component to use new service (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
alejsdev committed Jun 5, 2024
1 parent 0b16db4 commit ef76179
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions frontend/src/components/UserSettings/DeleteConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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",
Expand All @@ -52,7 +51,7 @@ const DeleteConfirmation = ({ isOpen, onClose }: DeleteProps) => {
})

const onSubmit = async () => {
mutation.mutate(currentUser!.id)
mutation.mutate()
}

return (
Expand Down

0 comments on commit ef76179

Please sign in to comment.