|
|
@ -36,7 +36,17 @@ export function useRespondToMarriageCaseMutation( |
|
|
...options, |
|
|
...options, |
|
|
mutationFn: (payload) => respondToMarriageCase(caseId, payload), |
|
|
mutationFn: (payload) => respondToMarriageCase(caseId, payload), |
|
|
onSuccess: async (data, variables, onMutateResult, context) => { |
|
|
onSuccess: async (data, variables, onMutateResult, context) => { |
|
|
if (data?.case) { |
|
|
|
|
|
|
|
|
if (variables?.action === "reject") { |
|
|
|
|
|
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { |
|
|
|
|
|
if (!old) return old; |
|
|
|
|
|
return { |
|
|
|
|
|
...old, |
|
|
|
|
|
status: "waiting", |
|
|
|
|
|
active_case: null, |
|
|
|
|
|
match_summary: null, |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (data?.case) { |
|
|
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { |
|
|
queryClient.setQueryData(marriageQueryKeys.profile(), (old: any) => { |
|
|
if (!old) return old; |
|
|
if (!old) return old; |
|
|
const updatedActiveCase = { |
|
|
const updatedActiveCase = { |
|
|
@ -63,14 +73,13 @@ export function useRespondToMarriageCaseMutation( |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await Promise.all([ |
|
|
|
|
|
queryClient.refetchQueries({ |
|
|
|
|
|
queryKey: marriageQueryKeys.profile(), |
|
|
|
|
|
}), |
|
|
|
|
|
queryClient.invalidateQueries({ |
|
|
|
|
|
queryKey: marriageQueryKeys.contactInfo(caseId), |
|
|
|
|
|
}), |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
queryClient.invalidateQueries({ |
|
|
|
|
|
queryKey: marriageQueryKeys.profile(), |
|
|
|
|
|
}); |
|
|
|
|
|
queryClient.invalidateQueries({ |
|
|
|
|
|
queryKey: marriageQueryKeys.contactInfo(caseId), |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
await options?.onSuccess?.(data, variables, onMutateResult, context); |
|
|
await options?.onSuccess?.(data, variables, onMutateResult, context); |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|