mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-16 06:05:58 +08:00
fix: error state is updated
This commit is contained in:
parent
b4833eeb0e
commit
574088ad54
@ -1,6 +1,7 @@
|
|||||||
|
import { notification } from 'antd';
|
||||||
import getAll from 'api/alerts/getAll';
|
import getAll from 'api/alerts/getAll';
|
||||||
import Spinner from 'components/Spinner';
|
import Spinner from 'components/Spinner';
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
|
|
||||||
@ -13,6 +14,14 @@ function ListAlertRules(): JSX.Element {
|
|||||||
cacheTime: 0,
|
cacheTime: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (status === 'error' || (status === 'success' && data.statusCode !== 200)) {
|
||||||
|
notification.error({
|
||||||
|
message: data?.error || t('something_went_wrong'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [data?.error, data?.statusCode, status, t]);
|
||||||
|
|
||||||
// api failed to load the data
|
// api failed to load the data
|
||||||
if (isError) {
|
if (isError) {
|
||||||
return <div>{data?.error || t('something_went_wrong')}</div>;
|
return <div>{data?.error || t('something_went_wrong')}</div>;
|
||||||
@ -20,7 +29,14 @@ function ListAlertRules(): JSX.Element {
|
|||||||
|
|
||||||
// api is successful but error is present
|
// api is successful but error is present
|
||||||
if (status === 'success' && data.statusCode !== 200) {
|
if (status === 'success' && data.statusCode !== 200) {
|
||||||
return <div>{data?.error || t('something_went_wrong')}</div>;
|
return (
|
||||||
|
<ListAlert
|
||||||
|
{...{
|
||||||
|
allAlertRules: [],
|
||||||
|
refetch,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case of loading
|
// in case of loading
|
||||||
|
Loading…
x
Reference in New Issue
Block a user