Add edit information account page

This commit is contained in:
2023-11-30 14:13:03 +07:00
parent 4befe61477
commit 45eba50509
9 changed files with 274 additions and 2 deletions
@@ -0,0 +1,25 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from 'react-hot-toast';
// Services
import { updateAccount as updateAccountFn } from '@service/authenticationService';
// Constants
import { UPDATE_ACCOUNT_SUCCESSFUL } from '@constant/messages';
const useUpdateAccount = () => {
const queryClient = useQueryClient();
const { mutate: updateAccount, isPending: isUpdating } = useMutation({
mutationFn: updateAccountFn,
onSuccess: (account) => {
toast.success(UPDATE_ACCOUNT_SUCCESSFUL);
queryClient.setQueryData(['account'], account.user);
},
onError: (err) => toast.error(err.message),
});
return { updateAccount, isUpdating };
};
export { useUpdateAccount };