Skip to content

Commit 99be1e8

Browse files
committed
refactor: streamline alert method by consolidating toast parameters
1 parent 6e3ef74 commit 99be1e8

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

adminforth/spa/src/adminforth.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,22 @@ class FrontendAPI implements FrontendAPIInterface {
9898
}
9999

100100
alert(params: AlertParams): void | Promise<string> | string {
101+
const toats = {
102+
message: params.message,
103+
messageHtml: params.messageHtml,
104+
variant: params.variant,
105+
timeout: params.timeout,
106+
buttons: params.buttons,
107+
}
101108
if (params.buttons && params.buttons.length > 0) {
102109
return new Promise<string>((resolve) => {
103-
// store a resolver with the toast so the Toast component can resolve it
104110
this.toastStore.addToast({
105-
message: params.message,
106-
messageHtml: params.messageHtml,
107-
variant: params.variant,
108-
timeout: params.timeout,
109-
buttons: params.buttons,
111+
...toats,
110112
onResolve: (value?: any) => resolve(String(value ?? '')),
111113
})
112114
})
113115
} else {
114-
this.toastStore.addToast({
115-
message: params.message,
116-
messageHtml: params.messageHtml,
117-
variant: params.variant,
118-
timeout: params.timeout,
119-
buttons: params.buttons,
120-
})
116+
this.toastStore.addToast({...toats})
121117
}
122118
}
123119

0 commit comments

Comments
 (0)