From b4833eeb0efbb44569d1a0da9665e98ce72560b9 Mon Sep 17 00:00:00 2001 From: Palash gupta Date: Tue, 10 May 2022 17:27:04 +0530 Subject: [PATCH] fix: list alerts rules is handled --- frontend/src/container/ListAlertRules/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/container/ListAlertRules/index.tsx b/frontend/src/container/ListAlertRules/index.tsx index abcf1efe58..a5c616bfe6 100644 --- a/frontend/src/container/ListAlertRules/index.tsx +++ b/frontend/src/container/ListAlertRules/index.tsx @@ -8,15 +8,22 @@ import ListAlert from './ListAlert'; function ListAlertRules(): JSX.Element { const { t } = useTranslation('common'); - const { data, isError, isLoading, refetch } = useQuery('allAlerts', { + const { data, isError, isLoading, refetch, status } = useQuery('allAlerts', { queryFn: getAll, cacheTime: 0, }); + // api failed to load the data if (isError) { return
{data?.error || t('something_went_wrong')}
; } + // api is successful but error is present + if (status === 'success' && data.statusCode !== 200) { + return
{data?.error || t('something_went_wrong')}
; + } + + // in case of loading if (isLoading || !data?.payload) { return ; }