profile + update address with location
This commit is contained in:
@@ -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),
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user