prile form:

This commit is contained in:
hamid zarghami
2025-09-16 10:46:02 +03:30
parent ab29dc26dd
commit 87bc7866fa
4 changed files with 229 additions and 113 deletions
+17 -1
View File
@@ -1,6 +1,7 @@
import { useQuery } from "@tanstack/react-query";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import * as api from "../service/Service";
import { useSharedStore } from "@/share/store/sharedStore";
import { UpdateProfileRequest } from "../types/ProfileTypes";
export const useGetProfile = () => {
const { isLogin } = useSharedStore();
@@ -10,3 +11,18 @@ export const useGetProfile = () => {
enabled: isLogin,
});
};
export const useUpdateProfile = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (profileData: UpdateProfileRequest) =>
api.updateProfile(profileData),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["profile"] });
},
onError: (error: any) => {
console.error("خطا در به‌روزرسانی پروفایل:", error);
},
});
};