Skip to content

Commit

Permalink
fix(vrack-services): error message not disappearing on overview page (#…
Browse files Browse the repository at this point in the history
…11561)

ref: MANAGER-14189

Signed-off-by: Nicolas Pierre-charles <nicolas.pierre-charles.ext@corp.ovh.com>
  • Loading branch information
chipp972 committed May 10, 2024
1 parent abfba61 commit 50dbdc6
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions packages/manager/apps/vrack-services/src/utils/vs-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,7 @@ export const useUpdateVrackServices = ({
const [isErrorVisible, setIsErrorVisible] = React.useState(false);
const queryClient = useQueryClient();

const {
mutateAsync: updateVS,
isPending,
isError,
error: updateError,
} = useMutation<
const { mutateAsync: updateVS, isPending, error: updateError } = useMutation<
ApiResponse<VrackServices>,
ApiError,
UpdateVrackServicesParams
Expand All @@ -105,9 +100,11 @@ export const useUpdateVrackServices = ({
queryClient.invalidateQueries({
queryKey: getVrackServicesResourceListQueryKey,
});
queryClient.invalidateQueries({
queryKey: getVrackServicesResourceQueryKey(result.data?.id || key),
});
if (result) {
queryClient.invalidateQueries({
queryKey: getVrackServicesResourceQueryKey(result.data?.id || key),
});
}
},
onSuccess: (result: ApiResponse<VrackServices>) => {
queryClient.setQueryData(
Expand Down Expand Up @@ -139,19 +136,16 @@ export const useUpdateVrackServices = ({
}, updateTriggerDelay);
onSuccess?.(result);
},
onError,
});

React.useEffect(() => {
if (isError) {
onError: (result) => {
setIsErrorVisible(true);
}
}, [isError]);
onError?.(result);
},
});

return {
updateVS,
isPending,
isErrorVisible,
isErrorVisible: updateError && isErrorVisible,
hideError: () => setIsErrorVisible(false),
updateError,
};
Expand Down

0 comments on commit 50dbdc6

Please sign in to comment.