fix(ui-144): alert catch the save errors

This commit is contained in:
Shekar Siri 2023-12-15 13:23:25 +01:00
parent 7ef7c0b3a0
commit 0820689c9c
2 changed files with 15 additions and 11 deletions

View file

@ -79,7 +79,7 @@ interface Props extends RouteComponentProps {
init: (alert: Alert) => void;
demo?: boolean;
webhooks: Array<any>;
triggerOptions: Record<string, any>;
triggerOptions?: Record<string, any>;
}
function AlertListItem(props: Props) {

View file

@ -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<void> => {
return new Promise<void>(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) => {