1
- import { createQueryKeyFactory } from '@/apis/createQueryKeyFactory ' ;
1
+ import getQueryKey from '@/apis/getQueryKey ' ;
2
2
import { type MissionCategory , type MissionItemTypeWithRecordId , type MissionVisibility } from '@/apis/schema/mission' ;
3
3
import {
4
4
useMutation ,
@@ -81,23 +81,17 @@ interface ModifyMissionResponse {
81
81
visibility : string ;
82
82
}
83
83
84
- const missionsQueryKey = [ 'missions' ] ;
85
-
86
84
export const useGetMissions = ( option ?: UseQueryOptions < GetMissionsResponse > ) => {
87
85
return useQuery < GetMissionsResponse > ( {
88
- queryKey : missionsQueryKey ,
86
+ queryKey : getQueryKey ( 'missions' ) ,
89
87
queryFn : MISSION_APIS . getMissions ,
90
88
...option ,
91
89
} ) ;
92
90
} ;
93
91
94
- const getMissionDetailQueryKey = createQueryKeyFactory < {
95
- missionId : string ;
96
- } > ( 'missionDetail' ) ;
97
-
98
92
export const useGetMissionDetail = ( missionId : string , option ?: UseQueryOptions < MissionContentType > ) => {
99
93
return useSuspenseQuery < MissionContentType > ( {
100
- queryKey : getMissionDetailQueryKey ( { missionId } ) ,
94
+ queryKey : getQueryKey ( 'missionDetail' , { missionId } ) ,
101
95
queryFn : ( ) => MISSION_APIS . getMissionDetail ( missionId ) ,
102
96
...option ,
103
97
} ) ;
@@ -108,7 +102,7 @@ export const useGetMissionDetailNoSuspense = (
108
102
option ?: Omit < UseQueryOptions < MissionContentType > , 'enabled' > , // TODO 수정 필요, 임시 방편
109
103
) => {
110
104
return useQuery < MissionContentType > ( {
111
- queryKey : getMissionDetailQueryKey ( { missionId } ) ,
105
+ queryKey : getQueryKey ( 'missionDetail' , { missionId } ) ,
112
106
queryFn : ( ) => MISSION_APIS . getMissionDetail ( missionId ) ,
113
107
enabled : Boolean ( missionId ) ,
114
108
...option ,
@@ -130,7 +124,7 @@ export const useDeleteMissionMutation = (missionId: string, option?: UseMutation
130
124
return useMutation ( {
131
125
mutationFn : ( ) => MISSION_APIS . deleteMission ( missionId ) ,
132
126
onSuccess : async ( ...data ) => {
133
- await queryClient . invalidateQueries ( { queryKey : missionsQueryKey } ) ;
127
+ await queryClient . invalidateQueries ( { queryKey : getQueryKey ( 'missions' ) } ) ;
134
128
option ?. onSuccess ?.( ...data ) ;
135
129
} ,
136
130
...option ,
0 commit comments