🆙 Update React Query to TanStack Query (#1153)
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
useColorModeValue,
|
||||
} from "@chakra-ui/react"
|
||||
import { type SubmitHandler, useForm } from "react-hook-form"
|
||||
import { useMutation } from "react-query"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
|
||||
import { type ApiError, type UpdatePassword, UsersService } from "../../client"
|
||||
import useCustomToast from "../../hooks/useCustomToast"
|
||||
@@ -34,20 +34,18 @@ const ChangePassword = () => {
|
||||
criteriaMode: "all",
|
||||
})
|
||||
|
||||
const mutation = useMutation(
|
||||
(data: UpdatePassword) =>
|
||||
const mutation = useMutation({
|
||||
mutationFn: (data: UpdatePassword) =>
|
||||
UsersService.updatePasswordMe({ requestBody: data }),
|
||||
{
|
||||
onSuccess: () => {
|
||||
showToast("Success!", "Password updated.", "success")
|
||||
reset()
|
||||
},
|
||||
onError: (err: ApiError) => {
|
||||
const errDetail = (err.body as any)?.detail
|
||||
showToast("Something went wrong.", `${errDetail}`, "error")
|
||||
},
|
||||
onSuccess: () => {
|
||||
showToast("Success!", "Password updated.", "success")
|
||||
reset()
|
||||
},
|
||||
)
|
||||
onError: (err: ApiError) => {
|
||||
const errDetail = (err.body as any)?.detail
|
||||
showToast("Something went wrong.", `${errDetail}`, "error")
|
||||
},
|
||||
})
|
||||
|
||||
const onSubmit: SubmitHandler<UpdatePasswordForm> = async (data) => {
|
||||
mutation.mutate(data)
|
||||
|
Reference in New Issue
Block a user