@visns-studio/visns-components 2.3.6 → 2.3.7
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/components/crm/Notification.jsx +33 -31
- package/package.json +1 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from
|
|
2
|
-
import { useNavigate } from
|
|
3
|
-
import moment from
|
|
4
|
-
import parse from
|
|
5
|
-
import { TooltipWrapper } from
|
|
6
|
-
import { toast } from
|
|
7
|
-
import { Bell, CircleX } from
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import parse from 'html-react-parser';
|
|
5
|
+
import { TooltipWrapper } from 'react-tooltip';
|
|
6
|
+
import { toast } from 'react-toastify';
|
|
7
|
+
import { Bell, CircleX } from 'akar-icons';
|
|
8
8
|
|
|
9
|
-
import CustomFetch from
|
|
9
|
+
import CustomFetch from './Fetch';
|
|
10
10
|
|
|
11
11
|
function Notification(props) {
|
|
12
12
|
let interval;
|
|
13
13
|
const navigate = useNavigate();
|
|
14
14
|
const wrapperRef = useRef(null);
|
|
15
|
-
const [containerClass] = useState(
|
|
16
|
-
const [divClass] = useState(
|
|
17
|
-
const [iconBellBlinkClass] = useState(
|
|
18
|
-
const [iconBellClass] = useState(
|
|
19
|
-
const [iconXClass] = useState(
|
|
20
|
-
const [actionClass] = useState(
|
|
15
|
+
const [containerClass] = useState('notibox');
|
|
16
|
+
const [divClass] = useState('notibox-item');
|
|
17
|
+
const [iconBellBlinkClass] = useState('cis-bell-exclamation noti');
|
|
18
|
+
const [iconBellClass] = useState('cis-bell-exclamation');
|
|
19
|
+
const [iconXClass] = useState('cis-x-circle noti-read');
|
|
20
|
+
const [actionClass] = useState('notibox-actions');
|
|
21
21
|
const [items, setItems] = useState([]);
|
|
22
22
|
const [show, setShow] = useState(false);
|
|
23
23
|
const { setSystemAuth } = props;
|
|
24
24
|
|
|
25
25
|
const fetchNotification = () => {
|
|
26
26
|
CustomFetch(
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
'/ajax/user/notifications',
|
|
28
|
+
'POST',
|
|
29
29
|
{},
|
|
30
30
|
function (result) {
|
|
31
31
|
setItems(result.data);
|
|
32
32
|
},
|
|
33
33
|
function (error) {
|
|
34
|
-
if (String(error) ===
|
|
35
|
-
window.open(
|
|
34
|
+
if (String(error) === 'CSRF token mismatch.') {
|
|
35
|
+
window.open('/login');
|
|
36
36
|
} else {
|
|
37
|
-
if (error ===
|
|
37
|
+
if (error === 'Unauthenticated.') {
|
|
38
38
|
setSystemAuth(false);
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -67,8 +67,8 @@ function Notification(props) {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
CustomFetch(
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
'/ajax/user/notification/markasread',
|
|
71
|
+
'POST',
|
|
72
72
|
formData,
|
|
73
73
|
function () {
|
|
74
74
|
fetchNotification();
|
|
@@ -89,8 +89,8 @@ function Notification(props) {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
CustomFetch(
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
'/ajax/user/notification/markasread',
|
|
93
|
+
'POST',
|
|
94
94
|
formData,
|
|
95
95
|
function () {
|
|
96
96
|
fetchNotification();
|
|
@@ -109,7 +109,7 @@ function Notification(props) {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
const showAllNotifications = () => {
|
|
112
|
-
navigate(
|
|
112
|
+
navigate('/notifications');
|
|
113
113
|
setShow(false);
|
|
114
114
|
};
|
|
115
115
|
|
|
@@ -117,15 +117,17 @@ function Notification(props) {
|
|
|
117
117
|
fetchNotification();
|
|
118
118
|
|
|
119
119
|
interval = setInterval(() => {
|
|
120
|
-
|
|
120
|
+
if (!document.hidden) {
|
|
121
|
+
fetchNotification();
|
|
122
|
+
}
|
|
121
123
|
}, 60000);
|
|
122
124
|
|
|
123
|
-
document.addEventListener(
|
|
125
|
+
document.addEventListener('mousedown', handleClick, false);
|
|
124
126
|
|
|
125
127
|
return function cleanup() {
|
|
126
128
|
clearInterval(interval);
|
|
127
129
|
|
|
128
|
-
document.addEventListener(
|
|
130
|
+
document.addEventListener('mousedown', handleClick, false);
|
|
129
131
|
};
|
|
130
132
|
}, []);
|
|
131
133
|
|
|
@@ -157,15 +159,15 @@ function Notification(props) {
|
|
|
157
159
|
size={19}
|
|
158
160
|
strokeWidth={2}
|
|
159
161
|
className={iconBellClass}
|
|
160
|
-
/>{
|
|
161
|
-
{parse(item.data.label)}{
|
|
162
|
+
/>{' '}
|
|
163
|
+
{parse(item.data.label)}{' '}
|
|
162
164
|
<span>
|
|
163
165
|
[
|
|
164
166
|
{moment(item.created_at).format(
|
|
165
|
-
|
|
167
|
+
'DD/MM - H:mma'
|
|
166
168
|
)}
|
|
167
169
|
]
|
|
168
|
-
</span>{
|
|
170
|
+
</span>{' '}
|
|
169
171
|
<button onClick={markAsRead}>
|
|
170
172
|
<CircleX
|
|
171
173
|
size={24}
|
package/package.json
CHANGED