Add base kubernetes support final fix 4
This commit is contained in:
@@ -90,24 +90,35 @@ export const useUpdateStep = (
|
||||
|
||||
export const useMarkStepCompleted = (
|
||||
options?: UseMutationOptions<
|
||||
UserProgress,
|
||||
ApiError,
|
||||
UserProgress,
|
||||
ApiError,
|
||||
{ userId: string; stepName: string; data?: Record<string, any> }
|
||||
>
|
||||
) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
return useMutation<
|
||||
UserProgress,
|
||||
ApiError,
|
||||
UserProgress,
|
||||
ApiError,
|
||||
{ userId: string; stepName: string; data?: Record<string, any> }
|
||||
>({
|
||||
mutationFn: ({ userId, stepName, data }) =>
|
||||
mutationFn: ({ userId, stepName, data }) =>
|
||||
onboardingService.markStepCompleted(userId, stepName, data),
|
||||
onSuccess: (data, { userId }) => {
|
||||
// Update progress cache
|
||||
// Update progress cache with new data
|
||||
queryClient.setQueryData(onboardingKeys.progress(userId), data);
|
||||
|
||||
// Invalidate the query to ensure fresh data on next access
|
||||
queryClient.invalidateQueries({ queryKey: onboardingKeys.progress(userId) });
|
||||
},
|
||||
onError: (error, { userId, stepName }) => {
|
||||
console.error(`Failed to complete step ${stepName} for user ${userId}:`, error);
|
||||
|
||||
// Invalidate queries on error to ensure we get fresh data
|
||||
queryClient.invalidateQueries({ queryKey: onboardingKeys.progress(userId) });
|
||||
},
|
||||
// Prevent duplicate requests by using the step name as a mutation key
|
||||
mutationKey: (variables) => ['markStepCompleted', variables?.userId, variables?.stepName],
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user