mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 04:01:59 +08:00
fix: error handling is updated for the trigger alerts
This commit is contained in:
parent
53528f1045
commit
e06f020162
@ -1,7 +1,9 @@
|
|||||||
|
import { notification } from 'antd';
|
||||||
import getTriggeredApi from 'api/alerts/getTriggered';
|
import getTriggeredApi from 'api/alerts/getTriggered';
|
||||||
import Spinner from 'components/Spinner';
|
import Spinner from 'components/Spinner';
|
||||||
import { State } from 'hooks/useFetch';
|
import { State } from 'hooks/useFetch';
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { PayloadProps } from 'types/api/alerts/getTriggered';
|
import { PayloadProps } from 'types/api/alerts/getTriggered';
|
||||||
|
|
||||||
import TriggerComponent from './TriggeredAlert';
|
import TriggerComponent from './TriggeredAlert';
|
||||||
@ -14,6 +16,7 @@ function TriggeredAlerts(): JSX.Element {
|
|||||||
success: false,
|
success: false,
|
||||||
payload: [],
|
payload: [],
|
||||||
});
|
});
|
||||||
|
const { t } = useTranslation(['common']);
|
||||||
|
|
||||||
const fetchData = useCallback(async () => {
|
const fetchData = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
@ -56,8 +59,16 @@ function TriggeredAlerts(): JSX.Element {
|
|||||||
fetchData();
|
fetchData();
|
||||||
}, [fetchData]);
|
}, [fetchData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (groupState.error) {
|
||||||
|
notification.error({
|
||||||
|
message: groupState.errorMessage || t('something_went_wrong'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [groupState.error, groupState.errorMessage, t]);
|
||||||
|
|
||||||
if (groupState.error) {
|
if (groupState.error) {
|
||||||
return <div>{groupState.errorMessage}</div>;
|
return <TriggerComponent allAlerts={[]} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupState.loading || groupState.payload === undefined) {
|
if (groupState.loading || groupState.payload === undefined) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user