l-min-components 1.0.680 → 1.0.683
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/package.json
CHANGED
|
@@ -47,6 +47,7 @@ const AppMainLayout = () => {
|
|
|
47
47
|
const [affiliatesActive, setAffiliatesActive] = useState(false);
|
|
48
48
|
const [accessToken, setAccessToken] = useState("");
|
|
49
49
|
const [envType, setEnvType] = useState("");
|
|
50
|
+
const [newNotifications, setNewNotifications] = useState([]);
|
|
50
51
|
const { setDefaultAccount, handleSetDefaultAccount } = useHeader();
|
|
51
52
|
|
|
52
53
|
useEffect(() => {
|
|
@@ -148,13 +149,15 @@ const AppMainLayout = () => {
|
|
|
148
149
|
affiliatesActive,
|
|
149
150
|
accessToken,
|
|
150
151
|
envType,
|
|
152
|
+
newNotifications,
|
|
153
|
+
setNewNotifications,
|
|
151
154
|
}}
|
|
152
155
|
>
|
|
153
156
|
<Layout
|
|
154
157
|
coming={coming}
|
|
155
158
|
hasLayoutBackgroundImage={hasLayoutBackgroundImage}
|
|
156
159
|
>
|
|
157
|
-
<HeaderComponent />
|
|
160
|
+
<HeaderComponent setNewNotifications={setNewNotifications} />
|
|
158
161
|
<MainLayout coming={coming}>
|
|
159
162
|
<LeftLayout>
|
|
160
163
|
<SideBar routes={leftNavMenu} />
|
|
@@ -131,6 +131,29 @@ const handleGetNotificationMarkRead = async () => {
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
+
//Notification List
|
|
135
|
+
const [{ ...notificationData }, getNotification] = useAxios(
|
|
136
|
+
{
|
|
137
|
+
method: "GET",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
manual: true,
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const handleGetNotification = async (read) => {
|
|
145
|
+
try {
|
|
146
|
+
await getNotification({
|
|
147
|
+
url: `/notify/v1/notifications/`,
|
|
148
|
+
params: {
|
|
149
|
+
read: read,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
} catch (err) {
|
|
153
|
+
console.log(err);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
134
157
|
return {
|
|
135
158
|
handleGetUserDetails,
|
|
136
159
|
userDetails,
|
|
@@ -145,7 +168,9 @@ const handleGetNotificationMarkRead = async () => {
|
|
|
145
168
|
generalNotificationCountData,
|
|
146
169
|
handleGeneralNotificationCount,
|
|
147
170
|
notificationMarkReadData,
|
|
148
|
-
handleGetNotificationMarkRead
|
|
171
|
+
handleGetNotificationMarkRead,
|
|
172
|
+
notificationData,
|
|
173
|
+
handleGetNotification
|
|
149
174
|
};
|
|
150
175
|
};
|
|
151
176
|
export default useHeader;
|
|
@@ -58,6 +58,8 @@ const HeaderComponent = (props) => {
|
|
|
58
58
|
generalNotificationCountData,
|
|
59
59
|
handleGeneralNotificationCount,
|
|
60
60
|
notificationMarkReadData,
|
|
61
|
+
notificationData,
|
|
62
|
+
handleGetNotification
|
|
61
63
|
} = useHeader();
|
|
62
64
|
const { pathname } = useLocation();
|
|
63
65
|
const { setGeneralData, generalData } = useContext(OutletContext);
|
|
@@ -273,14 +275,15 @@ const HeaderComponent = (props) => {
|
|
|
273
275
|
const socket = useRef();
|
|
274
276
|
const generalSocket = useRef();
|
|
275
277
|
const token = getCookie("access");
|
|
276
|
-
const
|
|
278
|
+
const defaultAcctId = getCookie("defaultAccountID");
|
|
279
|
+
const account_id = generalData?.defaultAccount?.id || defaultAcctId;
|
|
277
280
|
|
|
278
281
|
// websocket for all notification account
|
|
279
|
-
const websocket = new WebSocket(
|
|
280
|
-
`wss://${socketUrl}?account=${account_id}&authorization=${token}`
|
|
281
|
-
);
|
|
282
|
-
|
|
283
282
|
useEffect(() => {
|
|
283
|
+
const websocket = new WebSocket(
|
|
284
|
+
`wss://${socketUrl}?account=${account_id}&authorization=${token}`
|
|
285
|
+
);
|
|
286
|
+
|
|
284
287
|
websocket.onopen = () => {
|
|
285
288
|
//check if socket is connected
|
|
286
289
|
console.log("websocket connection established");
|
|
@@ -296,9 +299,12 @@ const HeaderComponent = (props) => {
|
|
|
296
299
|
const data = JSON.parse(event?.data); //check for incoming message from socket
|
|
297
300
|
if (data.event === "new.notification.result") {
|
|
298
301
|
if (data.data) {
|
|
302
|
+
props.setNewNotifications((prev) => [...prev, data.data]);
|
|
303
|
+
|
|
299
304
|
console.log(data);
|
|
300
305
|
handleGetUnreadNotification();
|
|
301
306
|
handleGeneralNotificationCount();
|
|
307
|
+
handleGetNotification();
|
|
302
308
|
}
|
|
303
309
|
}
|
|
304
310
|
}
|
|
@@ -309,14 +315,15 @@ const HeaderComponent = (props) => {
|
|
|
309
315
|
websocket.removeEventListener("message", handler);
|
|
310
316
|
console.log("websocket closed");
|
|
311
317
|
};
|
|
312
|
-
}, [
|
|
313
|
-
|
|
314
|
-
const websocket2 = new WebSocket(
|
|
315
|
-
`wss://${socketUrl}?account=${account_id}&authorization=${token}&room_id=${account_id}`
|
|
316
|
-
);
|
|
318
|
+
}, []);
|
|
317
319
|
|
|
318
320
|
// websocket for room
|
|
319
321
|
useEffect(() => {
|
|
322
|
+
|
|
323
|
+
const websocket2 = new WebSocket(
|
|
324
|
+
`wss://${socketUrl}?account=${account_id}&authorization=${token}&room_id=${account_id}`
|
|
325
|
+
);
|
|
326
|
+
|
|
320
327
|
websocket2.onopen = () => {
|
|
321
328
|
//check if socket is connected
|
|
322
329
|
console.log("room websocket connection established");
|
|
@@ -341,6 +348,7 @@ const HeaderComponent = (props) => {
|
|
|
341
348
|
if (data.status) {
|
|
342
349
|
handleGetUnreadNotification();
|
|
343
350
|
handleGeneralNotificationCount();
|
|
351
|
+
handleGetNotification();
|
|
344
352
|
}
|
|
345
353
|
}
|
|
346
354
|
}
|
|
@@ -351,7 +359,7 @@ const HeaderComponent = (props) => {
|
|
|
351
359
|
websocket2.removeEventListener("message", handler);
|
|
352
360
|
console.log("room websocket closed");
|
|
353
361
|
};
|
|
354
|
-
}, [
|
|
362
|
+
}, []);
|
|
355
363
|
|
|
356
364
|
useEffect(() => {
|
|
357
365
|
handleGetUnreadNotification();
|
|
@@ -250,7 +250,7 @@ const SideMenu = ({
|
|
|
250
250
|
onClick={() => {
|
|
251
251
|
if (
|
|
252
252
|
window.location.hostname.includes("staging") &&
|
|
253
|
-
window.location.
|
|
253
|
+
window.location.pathname.includes("developer")
|
|
254
254
|
) {
|
|
255
255
|
newTab
|
|
256
256
|
? window.open(path, "_blank")
|