Browse Source

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

pull/13907/head
Alejandra 1 year ago
committed by GitHub
parent
commit
ef76179f9f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 7
      frontend/src/components/UserSettings/DeleteConfirmation.tsx

7
frontend/src/components/UserSettings/DeleteConfirmation.tsx

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

Loading…
Cancel
Save