Add base kubernetes support final fix 4

This commit is contained in:
Urtzi Alfaro
2025-09-29 07:54:25 +02:00
parent 57f77638cc
commit 4777e59e7a
14 changed files with 1041 additions and 167 deletions

View File

@@ -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,
});
};