@@ -5,13 +5,16 @@ import Gps from "@/asset/map/gps.svg?react";
55import notContainTargetUrl from "@/asset/map/not-contain-target.svg?url" ;
66import positionIconUrl from "@/asset/map/position.svg?url" ;
77import { getDistance } from "@/utils/map" ;
8- import { useMutation , useQuery } from "@tanstack/react-query" ;
8+ import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query" ;
99import { join , map , replace } from "es-toolkit/compat" ;
1010import { Circle , Map , MapMarker } from "react-kakao-maps-sdk" ;
1111import { useNavigate } from "react-router" ;
1212
13+ import { useUserStore } from "@/stores/user" ;
1314import {
1415 generate_qo_getGoals ,
16+ generate_qo_getGoalsCheck ,
17+ generate_qo_getGoalsComplete ,
1518 generate_qo_postGoalsAchieve
1619} from "@/lib/react-query/queryOptions/goals" ;
1720import useUserLocation from "@/hooks/useUserLocation" ;
@@ -26,7 +29,10 @@ const DISTANCE_DIFFRENCE = 20;
2629
2730function MapCertification ( ) {
2831 // Hooks
32+ const { addPoint } = useUserStore ( ) ;
2933 const navigate = useNavigate ( ) ;
34+ const client = useQueryClient ( ) ;
35+
3036 const { center, position, setCenterToMyPosition, updateCenterWhenMapMoved } =
3137 useUserLocation ( ) ;
3238 const {
@@ -43,7 +49,16 @@ function MapCertification() {
4349 const { mutate, isPending } = useMutation ( {
4450 ...generate_qo_postGoalsAchieve ( 1 ) ,
4551 onSuccess : ( data ) => {
46- /** @todo 홈 페이지에 사용도되는 데이터 쿼리 무효화 필요, 응답값으로 point 받아 성공 페이지로 전달 */
52+ const progressGoalKey = generate_qo_getGoalsCheck . DELETE_KEY ( ) ;
53+ const completeGoalKey = generate_qo_getGoalsComplete . DELETE_KEY ( ) ;
54+
55+ Promise . all ( [
56+ client . invalidateQueries ( { queryKey : progressGoalKey } ) ,
57+ client . invalidateQueries ( { queryKey : completeGoalKey } )
58+ // client.invalidateQueries({ queryKey: ["home"] }) // 홈페이지 데이터 무효화
59+ ] ) ;
60+
61+ addPoint ( data . point ) ;
4762
4863 navigate ( "/map/certification/success" , {
4964 state : { name, point : data . point }
0 commit comments