mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-31 14:12:03 +08:00
fix: list alerts rules is handled
This commit is contained in:
parent
53528f1045
commit
b4833eeb0e
@ -8,15 +8,22 @@ import ListAlert from './ListAlert';
|
|||||||
|
|
||||||
function ListAlertRules(): JSX.Element {
|
function ListAlertRules(): JSX.Element {
|
||||||
const { t } = useTranslation('common');
|
const { t } = useTranslation('common');
|
||||||
const { data, isError, isLoading, refetch } = useQuery('allAlerts', {
|
const { data, isError, isLoading, refetch, status } = useQuery('allAlerts', {
|
||||||
queryFn: getAll,
|
queryFn: getAll,
|
||||||
cacheTime: 0,
|
cacheTime: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// api is successful but error is present
|
||||||
|
if (status === 'success' && data.statusCode !== 200) {
|
||||||
|
return <div>{data?.error || t('something_went_wrong')}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// in case of loading
|
||||||
if (isLoading || !data?.payload) {
|
if (isLoading || !data?.payload) {
|
||||||
return <Spinner height="75vh" tip="Loading Rules..." />;
|
return <Spinner height="75vh" tip="Loading Rules..." />;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user