From 0820689c9ca5809c18727c88296ee6df09353081 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 15 Dec 2023 13:23:25 +0100 Subject: [PATCH] fix(ui-144): alert catch the save errors --- .../components/Alerts/AlertListItem.tsx | 2 +- frontend/app/mstore/alertsStore.ts | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx b/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx index 8ea7e00e0..adcce4cb7 100644 --- a/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx +++ b/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx @@ -79,7 +79,7 @@ interface Props extends RouteComponentProps { init: (alert: Alert) => void; demo?: boolean; webhooks: Array; - triggerOptions: Record; + triggerOptions?: Record; } function AlertListItem(props: Props) { diff --git a/frontend/app/mstore/alertsStore.ts b/frontend/app/mstore/alertsStore.ts index 33665f861..23b19af70 100644 --- a/frontend/app/mstore/alertsStore.ts +++ b/frontend/app/mstore/alertsStore.ts @@ -38,16 +38,20 @@ export default class AlertsStore { } }; - save = async (inst: Alert) => { - this.loading = true; - try { - await alertsService.save(inst ? inst : this.instance); - this.instance.isExists = true; - } catch (e) { - console.error(e); - } finally { - this.loading = false; - } + save = (inst: Alert): Promise => { + return new Promise(async (resolve, reject) => { + this.loading = true; + try { + await alertsService.save(inst ? inst : this.instance); + this.instance.isExists = true; + resolve(); + } catch (e) { + console.error(e); + reject(e); + } finally { + this.loading = false; + } + }); }; remove = async (id: string) => {