@evlop/commons 1.0.118 → 1.0.121
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/data-sources/scopeDataSource.d.ts.map +1 -1
- package/dist/src/data-sources/scopeDataSource.js +1 -14
- package/dist/src/data-sources/scopeDataSource.js.map +1 -1
- package/dist/src/hooks/useDataSource.d.ts +4 -2
- package/dist/src/hooks/useDataSource.d.ts.map +1 -1
- package/dist/src/hooks/useDataSource.js +25 -20
- package/dist/src/hooks/useDataSource.js.map +1 -1
- package/dist/src/reducers/index.d.ts +2 -0
- package/dist/src/reducers/index.d.ts.map +1 -1
- package/dist/src/reducers/index.js +3 -0
- package/dist/src/reducers/index.js.map +1 -1
- package/dist/src/reducers/notifications.d.ts +55 -0
- package/dist/src/reducers/notifications.d.ts.map +1 -0
- package/dist/src/reducers/notifications.js +36 -0
- package/dist/src/reducers/notifications.js.map +1 -0
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scopeDataSource.d.ts","sourceRoot":"","sources":["../../../src/data-sources/scopeDataSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
1
|
+
{"version":3,"file":"scopeDataSource.d.ts","sourceRoot":"","sources":["../../../src/data-sources/scopeDataSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,QAAA,MAAM,eAAe,EAAE,WAEtB,CAAC;AAWF,eAAe,eAAe,CAAC"}
|
@@ -1,23 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const lodash_1 = require("lodash");
|
4
|
-
const uuid_1 = require("uuid");
|
5
|
-
const constants_1 = require("../constants");
|
6
4
|
const scopeDataSource = (options, { scope }) => {
|
7
5
|
return lodash_1.get(scope, lodash_1.get(options, 'path'));
|
8
6
|
};
|
9
|
-
scopeDataSource.keyExtractor = (
|
10
|
-
const path = lodash_1.get(options, 'path', '');
|
11
|
-
const scopeValue = lodash_1.get(scope, lodash_1.get(options, 'path'));
|
12
|
-
return uuid_1.v5([
|
13
|
-
path,
|
14
|
-
JSON.stringify(scopeValue),
|
15
|
-
// to detect change in collection
|
16
|
-
lodash_1.get(scopeValue, 'page', ''),
|
17
|
-
lodash_1.get(scopeValue, 'isLoading', ''),
|
18
|
-
lodash_1.get(scopeValue, 'hasMore', ''),
|
19
|
-
].join(':'), constants_1.DATA_SOURCE_KEY_NAMESPACE);
|
20
|
-
};
|
7
|
+
scopeDataSource.keyExtractor = () => 'scope';
|
21
8
|
scopeDataSource.displayName = 'Scope';
|
22
9
|
scopeDataSource.identifier = 'scope';
|
23
10
|
scopeDataSource.type = 'Object';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scopeDataSource.js","sourceRoot":"","sources":["../../../src/data-sources/scopeDataSource.ts"],"names":[],"mappings":";;AAAA,mCAA6B;
|
1
|
+
{"version":3,"file":"scopeDataSource.js","sourceRoot":"","sources":["../../../src/data-sources/scopeDataSource.ts"],"names":[],"mappings":";;AAAA,mCAA6B;AAI7B,MAAM,eAAe,GAAgB,CAAC,OAAO,EAAE,EAAC,KAAK,EAAC,EAAC,EAAE;IACjD,OAAO,YAAG,CAAC,KAAK,EAAC,YAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;AAC9C,CAAC,CAAC;AAEF,eAAe,CAAC,YAAY,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC;AAC7C,eAAe,CAAC,WAAW,GAAG,OAAO,CAAC;AACtC,eAAe,CAAC,UAAU,GAAG,OAAO,CAAC;AACrC,eAAe,CAAC,IAAI,GAAG,QAAQ,CAAC;AAChC,eAAe,CAAC,oBAAoB,GAAG;IACnC,EAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAG,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAC;CAEjG,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import { Collection } from '../classes';
|
2
|
+
declare type DataSourceName = 'static' | 'collection' | 'url' | 'scope' | any;
|
2
3
|
interface DataSourceOptions {
|
3
|
-
type
|
4
|
-
|
4
|
+
type?: DataSourceName;
|
5
|
+
memoize?: boolean;
|
5
6
|
params?: string;
|
6
7
|
transformer?: string;
|
7
8
|
data?: Object;
|
9
|
+
[key: string]: any;
|
8
10
|
}
|
9
11
|
declare type Data = Collection | Object;
|
10
12
|
export declare const useDataSource: (source: string | DataSourceOptions, options?: DataSourceOptions) => Data;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDataSource.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDataSource.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"useDataSource.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDataSource.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKxC,aAAK,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,KAAK,GAAG,OAAO,GAAG,GAAG,CAAC;AACtE,UAAU,iBAAiB;IACvB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAE;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAC,MAAM,GAAG,GAAG,CAAC;CACrB;AAED,aAAK,IAAI,GAAG,UAAU,GAAG,MAAM,CAAC;AAIhC,eAAO,MAAM,aAAa,WAAa,MAAM,GAAG,iBAAiB,YAAa,iBAAiB,KAAI,IA4GlG,CAAC"}
|
@@ -11,30 +11,27 @@ const classes_1 = require("../classes");
|
|
11
11
|
const reducers_1 = require("../reducers");
|
12
12
|
const useScope_1 = require("./useScope");
|
13
13
|
const useTemplate_1 = __importDefault(require("./useTemplate"));
|
14
|
+
const defaultDatasourceOptions = { memoize: true };
|
14
15
|
const useDataSource = (source, options) => {
|
15
16
|
const dispatch = react_redux_1.useDispatch();
|
16
17
|
const template = useTemplate_1.default();
|
17
18
|
const scope = useScope_1.useScope();
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
19
|
+
const { dataSourceName, options: _dataSourceOptions } = react_1.useMemo(() => {
|
20
|
+
if (typeof source === 'object') {
|
21
|
+
return { dataSourceName: source.type, options: lodash_1.defaults(lodash_1.omit(source, ['type']), defaultDatasourceOptions) };
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
return { dataSourceName: source, options: lodash_1.defaults(options, defaultDatasourceOptions) };
|
25
|
+
}
|
26
|
+
}, [source, options]);
|
27
27
|
const dataSource = react_redux_1.useSelector(state => state.dataSource.dataSources[dataSourceName]);
|
28
|
-
|
28
|
+
// prepare datasource options by filling values from scope using template
|
29
|
+
const dataSourceOptions = react_1.useMemo(() => {
|
29
30
|
const paramNames = lodash_1.sortedUniq(lodash_1.map(lodash_1.get(dataSource, 'configurationOptions'), 'name'));
|
30
31
|
const templatedValues = lodash_1.reduce(paramNames, (acc, paramName) => (Object.assign(Object.assign({}, acc), { [paramName]: template(lodash_1.get(_dataSourceOptions, paramName)) })), {});
|
31
|
-
|
32
|
-
// to refresh value when scope changes for scoope data source
|
33
|
-
if (dataSourceName === 'scope' && templatedValues['path']) {
|
34
|
-
dependencies.push(lodash_1.get(scope, templatedValues['path']));
|
35
|
-
}
|
36
|
-
return { dependencies, dataSourceOptions: lodash_1.defaults(templatedValues, _dataSourceOptions) };
|
32
|
+
return lodash_1.defaults(templatedValues, _dataSourceOptions);
|
37
33
|
}, [scope, template, dataSourceName, dataSource, _dataSourceOptions]);
|
34
|
+
const { memoize } = dataSourceOptions;
|
38
35
|
const key = dataSource && dataSource.keyExtractor(dataSourceOptions, { scope, dispatch });
|
39
36
|
const currentValue = react_redux_1.useSelector(state => state.dataSource.data[key]);
|
40
37
|
const loadData = react_1.useCallback((params) => {
|
@@ -77,11 +74,15 @@ const useDataSource = (source, options) => {
|
|
77
74
|
});
|
78
75
|
}, [loadData, dataSourceOptions, scope, key]);
|
79
76
|
react_1.useEffect(() => {
|
80
|
-
if (
|
77
|
+
if (dataSourceName === 'scope')
|
78
|
+
return;
|
79
|
+
if (!currentValue || !memoize) {
|
81
80
|
loadData();
|
82
81
|
}
|
83
|
-
}, [key]);
|
84
|
-
|
82
|
+
}, [dataSourceName, key, memoize]);
|
83
|
+
const value = react_1.useMemo(() => {
|
84
|
+
if (dataSourceName === 'scope')
|
85
|
+
return;
|
85
86
|
if (lodash_1.get(dataSource, 'type') === 'Array') {
|
86
87
|
let items = lodash_1.get(currentValue, 'items');
|
87
88
|
items = Array.isArray(items) ? items : [];
|
@@ -102,7 +103,11 @@ const useDataSource = (source, options) => {
|
|
102
103
|
});
|
103
104
|
}
|
104
105
|
return currentValue || { isLoading: true };
|
105
|
-
}, [currentValue, dataSource]);
|
106
|
+
}, [dataSourceName, currentValue, dataSource]);
|
107
|
+
if (dataSourceName === 'scope') {
|
108
|
+
return lodash_1.get(scope, dataSourceOptions.path);
|
109
|
+
}
|
110
|
+
return value;
|
106
111
|
};
|
107
112
|
exports.useDataSource = useDataSource;
|
108
113
|
//# sourceMappingURL=useDataSource.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDataSource.js","sourceRoot":"","sources":["../../../src/hooks/useDataSource.tsx"],"names":[],"mappings":";;;;;;AAAA,mCAAiG;AACjG,iCAAwD;AACxD,6CAAuD;AACvD,wCAAwC;AACxC,0CAAmK;AACnK,yCAAsC;AACtC,gEAAwC;
|
1
|
+
{"version":3,"file":"useDataSource.js","sourceRoot":"","sources":["../../../src/hooks/useDataSource.tsx"],"names":[],"mappings":";;;;;;AAAA,mCAAiG;AACjG,iCAAwD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KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1C,OAAO,IAAI,oBAAU,CAAC,KAAK,EAAE;gBACzB,IAAI,EAAE,YAAG,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;gBAClC,QAAQ,EAAE,YAAG,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC;gBAC3C,SAAS,EAAE,CAAC,YAAY,IAAI,YAAG,CAAC,YAAY,EAAE,WAAW,EAAE,KAAK,CAAC;gBACjE,YAAY,EAAG,YAAG,CAAC,YAAY,EAAE,cAAc,EAAE,KAAK,CAAC;gBACvD,OAAO,EAAE,YAAG,CAAC,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC;gBAC5C,WAAW,EAAE,YAAG,CAAC,YAAY,EAAE,aAAa,EAAE,EAAE,CAAC;gBACjD,UAAU,EAAE,YAAG,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC;gBAC7C,YAAY,EAAE,YAAG,CAAC,YAAY,EAAE,cAAc,EAAE,CAAC,CAAC;gBAClD,OAAO,EAAE,QAAQ;gBACjB,MAAM;gBACN,QAAQ;gBACR,IAAI;gBACJ,QAAQ;aACX,CAAC,CAAC;SACN;QACD,OAAO,YAAY,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC/C,CAAC,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;IAE/C,IAAG,cAAc,KAAK,OAAO,EAAC;QAC1B,OAAO,YAAG,CAAC,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAA;KAC5C;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AA5GW,QAAA,aAAa,iBA4GxB"}
|
@@ -34,6 +34,7 @@ export declare const reducers: {
|
|
34
34
|
};
|
35
35
|
routes: (state: any, action: any) => any;
|
36
36
|
modals: (state: any, action: any) => any;
|
37
|
+
notifications: (state: import("./notifications").Notification[], action: any) => any[];
|
37
38
|
files: (state: any, action: any) => any;
|
38
39
|
};
|
39
40
|
export * from './adminMenus';
|
@@ -47,6 +48,7 @@ export * from './fonts';
|
|
47
48
|
export * from './pages';
|
48
49
|
export * from './icons';
|
49
50
|
export * from './modals';
|
51
|
+
export * from './notifications';
|
50
52
|
export * from './routes';
|
51
53
|
export * from './user';
|
52
54
|
export default reducers;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reducers/index.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reducers/index.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,eAAe,KAAyB,CAAC;AACtD,eAAO,MAAM,iBAAiB,KAA2B,CAAC;AAC1D,eAAO,MAAM,qBAAqB,KAAgC,CAAC;AACnE,eAAO,MAAM,eAAe,KAAyB,CAAC;AACtD,eAAO,MAAM,iBAAiB,KAA2B,CAAC;AAC1D,eAAO,MAAM,gBAAgB,KAA2B,CAAC;AAEzD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBpB,CAAC;AAEF,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,eAAe,QAAQ,CAAC"}
|
@@ -23,6 +23,7 @@ const user_1 = __importDefault(require("./user"));
|
|
23
23
|
const routes_1 = __importDefault(require("./routes"));
|
24
24
|
const icons_1 = __importDefault(require("./icons"));
|
25
25
|
const modals_1 = __importDefault(require("./modals"));
|
26
|
+
const notifications_1 = __importDefault(require("./notifications"));
|
26
27
|
const files_1 = __importDefault(require("./files"));
|
27
28
|
const fonts_1 = __importDefault(require("./fonts"));
|
28
29
|
const pages_1 = __importDefault(require("./pages"));
|
@@ -54,6 +55,7 @@ exports.reducers = {
|
|
54
55
|
config: config_1.default,
|
55
56
|
routes: routes_1.default,
|
56
57
|
modals: modals_1.default,
|
58
|
+
notifications: notifications_1.default,
|
57
59
|
files: files_1.default,
|
58
60
|
};
|
59
61
|
__exportStar(require("./adminMenus"), exports);
|
@@ -67,6 +69,7 @@ __exportStar(require("./fonts"), exports);
|
|
67
69
|
__exportStar(require("./pages"), exports);
|
68
70
|
__exportStar(require("./icons"), exports);
|
69
71
|
__exportStar(require("./modals"), exports);
|
72
|
+
__exportStar(require("./notifications"), exports);
|
70
73
|
__exportStar(require("./routes"), exports);
|
71
74
|
__exportStar(require("./user"), exports);
|
72
75
|
exports.default = exports.reducers;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reducers/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAkD;AAClD,qDAAuD;AACvD,sDAA8B;AAC9B,8DAAsC;AACtC,wDAAgC;AAChC,kDAA0B;AAC1B,sDAA8B;AAC9B,oDAA4B;AAC5B,sDAA8B;AAC9B,oDAA4B;AAC5B,oDAA4B;AAC5B,oDAA4B;AAC5B,8DAAsC;AACtC,8DAAsC;AACtC,8DAAsC;AAEtC,MAAM,cAAc,GAAG,8BAAiB,CAAC;AAE5B,QAAA,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AACzC,QAAA,iBAAiB,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AAC7C,QAAA,qBAAqB,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AACtD,QAAA,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AACzC,QAAA,iBAAiB,GAAG,cAAc,CAAC,QAAQ,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C,MAAM,CAAC,CAAC;AACzC,QAAA,iBAAiB,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AAC7C,QAAA,qBAAqB,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AACtD,QAAA,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AACzC,QAAA,iBAAiB,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AAC7C,QAAA,gBAAgB,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;AAE5C,QAAA,QAAQ,GAAG;IACpB,KAAK,EAAL,eAAK;IACL,KAAK,EAAE,uBAAe,CAAC,OAAO;IAC9B,OAAO,EAAE,yBAAiB,CAAC,OAAO;IAClC,OAAO,EAAE,wBAAgB,CAAC,OAAO;IACjC,OAAO,EAAE,yBAAiB,CAAC,OAAO;IAClC,UAAU,EAAV,oBAAU;IACV,IAAI,EAAE,oBAAW;IACjB,IAAI,EAAJ,cAAI;IACJ,OAAO,EAAP,iBAAO;IACP,UAAU,EAAV,oBAAU;IACV,UAAU,EAAV,oBAAU;IACV,UAAU,EAAV,oBAAU;IACV,KAAK,EAAL,eAAK;IACL,KAAK,EAAL,eAAK;IACL,MAAM,EAAN,gBAAM;IACN,MAAM,EAAN,gBAAM;IACN,MAAM,EAAN,gBAAM;IACN,aAAa,EAAb,uBAAa;IACb,KAAK,EAAL,eAAK;CACR,CAAC;AAEF,+CAA6B;AAC7B,+CAA6B;AAC7B,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,0CAAwB;AACxB,0CAAwB;AACxB,2CAAyB;AACzB,kDAAgC;AAChC,2CAAyB;AACzB,yCAAuB;AAEvB,kBAAe,gBAAQ,CAAC"}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
export declare const SHOW_NOTIFICATION = "notification/show";
|
2
|
+
export declare const REMOVE_NOTIFICATION = "notification/remove";
|
3
|
+
export interface Notification {
|
4
|
+
/**
|
5
|
+
* @description notification id
|
6
|
+
*/
|
7
|
+
id?: string;
|
8
|
+
/**
|
9
|
+
* @description notification title
|
10
|
+
*/
|
11
|
+
title: string;
|
12
|
+
/**
|
13
|
+
* @description notification message
|
14
|
+
*/
|
15
|
+
message?: string;
|
16
|
+
type?: 'info' | 'success' | 'error' | 'warning';
|
17
|
+
/**
|
18
|
+
* @description icon for notification
|
19
|
+
*/
|
20
|
+
icon?: string;
|
21
|
+
/**
|
22
|
+
* @description where should the notification be displayed
|
23
|
+
*/
|
24
|
+
position: 'top' | 'top-right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'top-left' | 'center';
|
25
|
+
/**
|
26
|
+
* Action buttons for notification
|
27
|
+
*/
|
28
|
+
buttons?: Array<{
|
29
|
+
title: string;
|
30
|
+
action: any;
|
31
|
+
}>;
|
32
|
+
/**
|
33
|
+
* @description for how long should the notification be displayed (in millisseconds)
|
34
|
+
* @default 5000
|
35
|
+
*/
|
36
|
+
timeout: number;
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* @description show in-app notification to user
|
40
|
+
* @param notification notification tp be displayed
|
41
|
+
* @returns redux action to show notification
|
42
|
+
*/
|
43
|
+
export declare const showNotification: (notification: Notification) => {
|
44
|
+
type: string;
|
45
|
+
notification: Notification & {
|
46
|
+
id: string;
|
47
|
+
};
|
48
|
+
};
|
49
|
+
export declare const removeNotification: (id: any) => {
|
50
|
+
type: string;
|
51
|
+
id: any;
|
52
|
+
};
|
53
|
+
declare const _default: (state: Array<Notification>, action: any) => any[];
|
54
|
+
export default _default;
|
55
|
+
//# sourceMappingURL=notifications.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/reducers/notifications.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAC,SAAS,GAAC,OAAO,GAAC,SAAS,CAAC;IAC1C;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,KAAK,GAAC,WAAW,GAAC,cAAc,GAAC,QAAQ,GAAC,aAAa,GAAC,UAAU,GAAC,QAAQ,CAAC;IACtF;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,GAAG,CAAC;KACf,CAAC,CAAA;IACF;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,iBAAkB,YAAY;;;;;CAGzD,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;CAG7B,CAAC;gCAIoB,MAAM,YAAY,CAAC;AAA1C,wBAYC"}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.removeNotification = exports.showNotification = exports.REMOVE_NOTIFICATION = exports.SHOW_NOTIFICATION = void 0;
|
4
|
+
const lodash_1 = require("lodash");
|
5
|
+
exports.SHOW_NOTIFICATION = 'notification/show';
|
6
|
+
exports.REMOVE_NOTIFICATION = 'notification/remove';
|
7
|
+
/**
|
8
|
+
* @description show in-app notification to user
|
9
|
+
* @param notification notification tp be displayed
|
10
|
+
* @returns redux action to show notification
|
11
|
+
*/
|
12
|
+
const showNotification = (notification) => ({
|
13
|
+
type: exports.SHOW_NOTIFICATION,
|
14
|
+
notification: lodash_1.assign({}, notification, { id: lodash_1.random(false).toString(36) }),
|
15
|
+
});
|
16
|
+
exports.showNotification = showNotification;
|
17
|
+
const removeNotification = (id) => ({
|
18
|
+
type: exports.REMOVE_NOTIFICATION,
|
19
|
+
id,
|
20
|
+
});
|
21
|
+
exports.removeNotification = removeNotification;
|
22
|
+
let initialState = [];
|
23
|
+
exports.default = (state = initialState, action) => {
|
24
|
+
switch (action.type) {
|
25
|
+
case exports.SHOW_NOTIFICATION:
|
26
|
+
return [
|
27
|
+
...state,
|
28
|
+
action.notification,
|
29
|
+
];
|
30
|
+
case exports.REMOVE_NOTIFICATION:
|
31
|
+
return state.filter(m => m.id !== action.id);
|
32
|
+
default:
|
33
|
+
return state;
|
34
|
+
}
|
35
|
+
};
|
36
|
+
//# sourceMappingURL=notifications.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/reducers/notifications.tsx"],"names":[],"mappings":";;;AAAA,mCAAwC;AAE3B,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAsCzD;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,YAA0B,EAAC,EAAE,CAAA,CAAC;IAC3D,IAAI,EAAE,yBAAiB;IACvB,YAAY,EAAE,eAAM,CAAC,EAAE,EAAC,YAAY,EAAE,EAAC,EAAE,EAAE,eAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;CAC3E,CAAC,CAAC;AAHU,QAAA,gBAAgB,oBAG1B;AAEI,MAAM,kBAAkB,GAAG,CAAC,EAAE,EAAC,EAAE,CAAA,CAAC;IACrC,IAAI,EAAE,2BAAmB;IACzB,EAAE;CACL,CAAC,CAAC;AAHU,QAAA,kBAAkB,sBAG5B;AAEH,IAAI,YAAY,GAAuB,EAAE,CAAC;AAE1C,kBAAe,CAAC,QAA6B,YAAY,EAAE,MAAM,EAAC,EAAE;IAChE,QAAQ,MAAM,CAAC,IAAI,EAAE;QACjB,KAAK,yBAAiB;YAClB,OAAO;gBACH,GAAG,KAAK;gBACR,MAAM,CAAC,YAAY;aACtB,CAAC;QACN,KAAK,2BAAmB;YACpB,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,CAAC,EAAE,KAAG,MAAM,CAAC,EAAE,CAAC,CAAC;QAC7C;YACI,OAAO,KAAK,CAAC;KACpB;AACL,CAAC,CAAA"}
|