profile + update address with location

This commit is contained in:
hamid zarghami
2025-09-17 10:53:52 +03:30
parent 87bc7866fa
commit bc22bbd6d9
8 changed files with 605 additions and 15 deletions
+16 -4
View File
@@ -1,7 +1,7 @@
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";
import { UpdateAddressType, UpdateProfileRequest } from "../types/ProfileTypes";
export const useGetProfile = () => {
const { isLogin } = useSharedStore();
@@ -21,8 +21,20 @@ export const useUpdateProfile = () => {
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["profile"] });
},
onError: (error: any) => {
console.error("خطا در به‌روزرسانی پروفایل:", error);
},
});
};
export const useGetAddressByLocation = (lat?: number, lon?: number) => {
return useQuery({
queryKey: ["address-by-location", lat, lon],
queryFn: () => api.getAddressByLocation(lat!, lon!),
enabled: lat !== undefined && lon !== undefined,
});
};
export const useUpdateAddress = () => {
return useMutation({
mutationFn: (addressData: UpdateAddressType) =>
api.updateAddress(addressData),
});
};