Compare commits

...

1 Commits

Author SHA1 Message Date
Vinicius Lourenço
f44a6aab9a fix(planned-downtime): notification breaking the page due to invalid description (#10492)
Some checks are pending
build-staging / prepare (push) Waiting to run
build-staging / js-build (push) Blocked by required conditions
build-staging / go-build (push) Blocked by required conditions
build-staging / staging (push) Blocked by required conditions
Release Drafter / update_release_draft (push) Waiting to run
2026-03-09 05:52:44 +00:00
4 changed files with 16 additions and 10 deletions

View File

@@ -33,6 +33,8 @@ import { ALL_TIME_ZONES } from 'utils/timeZoneUtil';
import 'dayjs/locale/en';
import { SOMETHING_WENT_WRONG } from '../../constants/api';
import { showErrorNotification } from '../../utils/error';
import { AlertRuleTags } from './PlannedDowntimeList';
import {
createEditDowntimeSchedule,
@@ -175,14 +177,14 @@ export function PlannedDowntimeForm(
} else {
notifications.error({
message: 'Error',
description: response.error || 'unexpected_error',
description:
typeof response.error === 'string'
? response.error
: response.error?.message || SOMETHING_WENT_WRONG,
});
}
} catch (e) {
notifications.error({
message: 'Error',
description: 'unexpected_error',
});
} catch (e: unknown) {
showErrorNotification(notifications, e as Error);
}
setSaveLoading(false);
},

View File

@@ -25,6 +25,7 @@ import { CalendarClock, PenLine, Trash2 } from 'lucide-react';
import { useAppContext } from 'providers/App/App';
import { USER_ROLES } from 'types/roles';
import { showErrorNotification } from '../../utils/error';
import {
formatDateTime,
getAlertOptionsFromIds,
@@ -359,7 +360,7 @@ export function PlannedDowntimeList({
useEffect(() => {
if (downtimeSchedules.isError) {
notifications.error(downtimeSchedules.error);
showErrorNotification(notifications, downtimeSchedules.error);
}
}, [downtimeSchedules.error, downtimeSchedules.isError, notifications]);

View File

@@ -137,7 +137,10 @@ export const deleteDowntimeHandler = ({
export const createEditDowntimeSchedule = async (
props: DowntimeScheduleUpdatePayload,
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
): Promise<
| SuccessResponse<PayloadProps>
| ErrorResponse<{ code: string; message: string } | string>
> => {
if (props.id) {
return updateDowntimeSchedule({ ...props });
}

View File

@@ -3,10 +3,10 @@ import { ErrorStatusCode, SuccessStatusCode } from 'types/common';
export type ApiResponse<T> = { data: T };
export interface ErrorResponse {
export interface ErrorResponse<ErrorObject = string> {
statusCode: ErrorStatusCode;
payload: null;
error: string;
error: ErrorObject;
message: string | null;
body?: string | null;
}