@webitel/ui-sdk 3.2.3 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import eventBus from '../../../scripts/eventBus';
|
|
2
2
|
|
|
3
|
-
const notifyTransformer = (
|
|
4
|
-
|
|
3
|
+
const notifyTransformer = (notificationObject) => {
|
|
4
|
+
/*
|
|
5
|
+
if passed arg is function, then this notification - static content,
|
|
6
|
+
predefined before actual transformer is called in applyTransform flow
|
|
7
|
+
*/
|
|
8
|
+
if (typeof notificationObject === 'function') {
|
|
9
|
+
/*
|
|
10
|
+
so, create a callback which will send notification with params, passed to it
|
|
11
|
+
*/
|
|
12
|
+
const callback = ({ type, text }) => eventBus.$emit('notification', { type, text });
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
and, then, return a function, which will be called in main applyTransform flow,
|
|
16
|
+
calling passed arg function with callback, and returning actual notify payload
|
|
17
|
+
*/
|
|
18
|
+
return (payload) => {
|
|
19
|
+
notificationObject({ callback });
|
|
20
|
+
return payload;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (notificationObject instanceof Error) {
|
|
5
24
|
eventBus.$emit('notification', {
|
|
6
25
|
type: 'error',
|
|
7
|
-
text:
|
|
26
|
+
text: notificationObject.response?.data?.detail || notificationObject.response?.data?.message,
|
|
8
27
|
});
|
|
9
28
|
}
|
|
10
|
-
return
|
|
29
|
+
return notificationObject;
|
|
11
30
|
};
|
|
12
31
|
|
|
13
32
|
export default notifyTransformer;
|