From e06f020162d367c00d423b60e66e79a5b0c29139 Mon Sep 17 00:00:00 2001 From: Palash gupta Date: Tue, 10 May 2022 18:30:22 +0530 Subject: [PATCH] fix: error handling is updated for the trigger alerts --- frontend/src/container/TriggeredAlerts/index.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/container/TriggeredAlerts/index.tsx b/frontend/src/container/TriggeredAlerts/index.tsx index a3762762df..787bdfb85b 100644 --- a/frontend/src/container/TriggeredAlerts/index.tsx +++ b/frontend/src/container/TriggeredAlerts/index.tsx @@ -1,7 +1,9 @@ +import { notification } from 'antd'; import getTriggeredApi from 'api/alerts/getTriggered'; import Spinner from 'components/Spinner'; import { State } from 'hooks/useFetch'; import React, { useCallback, useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; import { PayloadProps } from 'types/api/alerts/getTriggered'; import TriggerComponent from './TriggeredAlert'; @@ -14,6 +16,7 @@ function TriggeredAlerts(): JSX.Element { success: false, payload: [], }); + const { t } = useTranslation(['common']); const fetchData = useCallback(async () => { try { @@ -56,8 +59,16 @@ function TriggeredAlerts(): JSX.Element { fetchData(); }, [fetchData]); + useEffect(() => { + if (groupState.error) { + notification.error({ + message: groupState.errorMessage || t('something_went_wrong'), + }); + } + }, [groupState.error, groupState.errorMessage, t]); + if (groupState.error) { - return
{groupState.errorMessage}
; + return ; } if (groupState.loading || groupState.payload === undefined) {