blob: 328e046bbd4da051b2f737ffb1378f9cc3cb29be [file] [log] [blame]
svishnev7c727c12018-05-24 13:20:51 +03001/*
2 * Copyright © 2016-2018 European Support Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import UUID from 'uuid-js';
17
18export const actionTypes = {
svishnevbacc7152018-11-05 12:11:30 +020019 ADD_NOTIFICATION: 'notifications/ADD_NOTIFICATION',
20 REMOVE_NOTIFICATION: 'notifications/REMOVE_NOTIFICATION'
svishnev7c727c12018-05-24 13:20:51 +030021};
22
23export const notificationActions = {
24 showNotification: item => ({
25 type: actionTypes.ADD_NOTIFICATION,
26 payload: {
27 ...item,
28 id: UUID.create().toString()
29 }
30 }),
31
32 showSuccess: ({ title, message, timeout }) =>
33 notificationActions.showNotification({
34 title,
35 message,
36 timeout,
37 type: 'success'
38 }),
39 showInfo: ({ title, message, timeout }) =>
40 notificationActions.showNotification({
41 title,
42 message,
43 timeout,
44 type: 'info'
45 }),
46 showWarning: ({ title, message, timeout }) =>
47 notificationActions.showNotification({
48 title,
49 message,
50 timeout,
51 type: 'warning'
52 }),
53 showError: ({ title, message, timeout }) =>
54 notificationActions.showNotification({
55 title,
56 message,
57 timeout,
58 type: 'error'
59 }),
60 removeNotification: item => ({
61 type: actionTypes.REMOVE_NOTIFICATION,
62 payload: item
63 })
64};
65
66export const notificationTimeout = 4000;