UNPKG

2.2 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.removeFirstNotification = exports.addMultipleNotifications = exports.addOneNotification = exports.deactivateLoading = exports.activateLoading = void 0;
9
10var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
11
12var _objectSpread2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectSpread"));
13
14var _lodash = _interopRequireDefault(require("lodash.curryright"));
15
16var activateLoading = function activateLoading(uiState) {
17 return (0, _objectSpread2.default)({}, uiState, {
18 isLoading: true
19 });
20};
21
22exports.activateLoading = activateLoading;
23
24var deactivateLoading = function deactivateLoading(uiState) {
25 return (0, _objectSpread2.default)({}, uiState, {
26 isLoading: false
27 });
28};
29
30exports.deactivateLoading = deactivateLoading;
31var 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});
40exports.addOneNotification = addOneNotification;
41var 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});
51exports.addMultipleNotifications = addMultipleNotifications;
52
53var removeFirstNotification = function removeFirstNotification(uiState) {
54 return (0, _objectSpread2.default)({}, uiState, {
55 notifications: uiState.notifications.splice(1)
56 });
57};
58
59exports.removeFirstNotification = removeFirstNotification;
\No newline at end of file