1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.removeFirstNotification = exports.addMultipleNotifications = exports.addOneNotification = exports.deactivateLoading = exports.activateLoading = void 0;
|
9 |
|
10 | var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
11 |
|
12 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectSpread"));
|
13 |
|
14 | var _lodash = _interopRequireDefault(require("lodash.curryright"));
|
15 |
|
16 | var activateLoading = function activateLoading(uiState) {
|
17 | return (0, _objectSpread2.default)({}, uiState, {
|
18 | isLoading: true
|
19 | });
|
20 | };
|
21 |
|
22 | exports.activateLoading = activateLoading;
|
23 |
|
24 | var deactivateLoading = function deactivateLoading(uiState) {
|
25 | return (0, _objectSpread2.default)({}, uiState, {
|
26 | isLoading: false
|
27 | });
|
28 | };
|
29 |
|
30 | exports.deactivateLoading = deactivateLoading;
|
31 | var addOneNotification = (0, _lodash.default)(function (uiState, notification) {
|
32 | var _uiState$notification;
|
33 |
|
34 | return (0, _objectSpread2.default)({}, uiState, {
|
35 | notifications: (_uiState$notification = uiState.notifications).concat.apply(_uiState$notification, (0, _toConsumableArray2.default)(notification ? [typeof notification === 'string' ? {
|
36 | message: notification
|
37 | } : notification] : []))
|
38 | });
|
39 | });
|
40 | exports.addOneNotification = addOneNotification;
|
41 | var addMultipleNotifications = (0, _lodash.default)(function (uiState) {
|
42 | var notifications = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
43 | return (0, _objectSpread2.default)({}, uiState, {
|
44 | notifications: uiState.notifications.concat(notifications.map(function (notification) {
|
45 | return typeof notification === 'string' ? {
|
46 | message: notification
|
47 | } : notification;
|
48 | }))
|
49 | });
|
50 | });
|
51 | exports.addMultipleNotifications = addMultipleNotifications;
|
52 |
|
53 | var removeFirstNotification = function removeFirstNotification(uiState) {
|
54 | return (0, _objectSpread2.default)({}, uiState, {
|
55 | notifications: uiState.notifications.splice(1)
|
56 | });
|
57 | };
|
58 |
|
59 | exports.removeFirstNotification = removeFirstNotification; |
\ | No newline at end of file |