l-min-components 1.0.1002 → 1.0.1005

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.0.1002",
3
+ "version": "1.0.1005",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -111,7 +111,7 @@ export const DevBannerWrapper = styled.div`
111
111
  .dev_banner_title {
112
112
  color: #febf10;
113
113
  text-align: center;
114
- font-family: "Nunito Sans";
114
+ font-family: "Nunito" sans-serif;
115
115
  font-size: 18px;
116
116
  font-weight: 700;
117
117
  letter-spacing: 0.36px;
@@ -122,7 +122,7 @@ export const DevBannerWrapper = styled.div`
122
122
  .dev_banner_subtitle {
123
123
  color: #febf10;
124
124
  text-align: center;
125
- font-family: "Nunito Sans";
125
+ font-family: "Nunito" sans-serif;
126
126
  font-size: 18px;
127
127
  font-weight: 600;
128
128
  letter-spacing: 0.36px;
@@ -131,7 +131,7 @@ export const DevBannerWrapper = styled.div`
131
131
  .dev_banner_txt {
132
132
  color: #fff;
133
133
  text-align: center;
134
- font-family: "Nunito Sans";
134
+ font-family: "Nunito" sans-serif;
135
135
  font-size: 16px;
136
136
  font-weight: 400;
137
137
  letter-spacing: 0.32px;
@@ -101,9 +101,35 @@ const useHeader = () => {
101
101
  }
102
102
  );
103
103
 
104
- const handleGetUnreadNotification = async (read = false) => {
104
+ const handleGetUnreadNotification = async (
105
+ account_type = "",
106
+ read = false
107
+ ) => {
105
108
  try {
106
109
  await getUnreadNotification({
110
+ url: `/notify/v1/${account_type}/notifications/`,
111
+ params: {
112
+ read: read,
113
+ },
114
+ });
115
+ } catch (err) {
116
+ //console.log(err);
117
+ }
118
+ };
119
+
120
+ const [{ ...unreadNotificationPersonalData }, getUnreadNotificationPersonal] =
121
+ useAxios(
122
+ {
123
+ method: "GET",
124
+ },
125
+ {
126
+ manual: true,
127
+ }
128
+ );
129
+
130
+ const handleGetUnreadNotificationPersonal = async (read = false) => {
131
+ try {
132
+ await getUnreadNotificationPersonal({
107
133
  url: `/notify/v1/notifications/`,
108
134
  params: {
109
135
  read: read,
@@ -125,9 +151,32 @@ const useHeader = () => {
125
151
  }
126
152
  );
127
153
 
128
- const handleGeneralNotificationCount = async () => {
154
+ const handleGeneralNotificationCount = async (account_type = "") => {
129
155
  try {
130
156
  await generalNotificationCount({
157
+ url: `/notify/v1/${account_type}/notifications/general_notification_count/`,
158
+ });
159
+ } catch (err) {
160
+ //console.log(err);
161
+ }
162
+ };
163
+
164
+ // general notification count personal
165
+ const [
166
+ { ...generalNotificationCountPersonalData },
167
+ generalNotificationCountPersonal,
168
+ ] = useAxios(
169
+ {
170
+ method: "GET",
171
+ },
172
+ {
173
+ manual: true,
174
+ }
175
+ );
176
+
177
+ const handleGeneralNotificationCountPersonal = async () => {
178
+ try {
179
+ await generalNotificationCountPersonal({
131
180
  url: `/notify/v1/notifications/general_notification_count/`,
132
181
  });
133
182
  } catch (err) {
@@ -145,9 +194,32 @@ const useHeader = () => {
145
194
  }
146
195
  );
147
196
 
148
- const handleGetNotificationMarkRead = async () => {
197
+ const handleGetNotificationMarkRead = async (account_type = "") => {
149
198
  try {
150
199
  await getNotificationMarkRead({
200
+ url: `/notify/v1/${account_type}/notifications/mark_all_as_read/`,
201
+ });
202
+ } catch (err) {
203
+ //console.log(err);
204
+ }
205
+ };
206
+
207
+ // Mark All Notification as Read Notification Personal acct
208
+ const [
209
+ { ...notificationMarkReadPersonalData },
210
+ getNotificationMarkReadPersonal,
211
+ ] = useAxios(
212
+ {
213
+ method: "PUT",
214
+ },
215
+ {
216
+ manual: true,
217
+ }
218
+ );
219
+
220
+ const handleGetNotificationMarkReadPersonal = async () => {
221
+ try {
222
+ await getNotificationMarkReadPersonal({
151
223
  url: `/notify/v1/notifications/mark_all_as_read/`,
152
224
  });
153
225
  } catch (err) {
@@ -165,10 +237,10 @@ const useHeader = () => {
165
237
  }
166
238
  );
167
239
 
168
- const handleGetNotification = async (read) => {
240
+ const handleGetNotification = async (account_type = "", read) => {
169
241
  try {
170
242
  await getNotification({
171
- url: `/notify/v1/notifications/`,
243
+ url: `/notify/v1/${account_type}/notifications/`,
172
244
  params: {
173
245
  read: read,
174
246
  },
@@ -243,7 +315,13 @@ const useHeader = () => {
243
315
  retrieveUserDetailsData,
244
316
  handleRetrieveUserDetails,
245
317
  updateUserAccountData,
246
- handleUpdateUserAccount
318
+ handleUpdateUserAccount,
319
+ notificationMarkReadPersonalData,
320
+ handleGetNotificationMarkReadPersonal,
321
+ unreadNotificationPersonalData,
322
+ handleGetUnreadNotificationPersonal,
323
+ generalNotificationCountPersonalData,
324
+ handleGeneralNotificationCountPersonal,
247
325
  };
248
326
  };
249
327
  export default useHeader;
@@ -68,16 +68,31 @@ const HeaderComponent = (props) => {
68
68
  const { setGeneralData, generalData, notificationMarkReadData } =
69
69
  useContext(OutletContext);
70
70
  const [selectedAccount, setSelectedAccount] = useState();
71
+ const [accountType, setAccountType] = useState("");
71
72
  const { setDefaultAccount, handleSetDefaultAccount } = useHeader();
73
+ const currentAccountType = selectedAccount?.type
74
+ ? selectedAccount?.type?.toLowerCase()
75
+ : userAccountsDetail?.data?.[0]?.type?.toLowerCase();
76
+
77
+ useEffect(() => {
78
+ if(currentAccountType) {
79
+ setAccountType(currentAccountType)
80
+ }
81
+ }, [currentAccountType])
72
82
 
73
83
  useEffect(() => {
74
84
  setIsOpen(false);
75
85
  handleGetUserAccountsDetail();
76
86
  handleGetUserDetails();
77
87
  handleGetDefaultAccount();
78
- handleGetUnreadNotification();
79
88
  }, []);
80
89
 
90
+ useEffect(() => {
91
+ if (accountType) {
92
+ handleGetUnreadNotification(accountType);
93
+ }
94
+ }, [accountType]);
95
+
81
96
  // Merge the notification_count into the results data using find
82
97
 
83
98
  const allUserAccountsDetail = userAccountsDetail?.data?.results.map(
@@ -93,8 +108,8 @@ const HeaderComponent = (props) => {
93
108
  );
94
109
 
95
110
  useEffect(() => {
96
- handleGeneralNotificationCount();
97
- }, []);
111
+ if (accountType) handleGeneralNotificationCount(accountType);
112
+ }, [accountType]);
98
113
 
99
114
  useEffect(() => {
100
115
  if (userAccountsDetail?.data) {
@@ -297,12 +312,12 @@ const HeaderComponent = (props) => {
297
312
  // websocket for all notification account
298
313
  useEffect(() => {
299
314
  const websocket = new WebSocket(
300
- `wss://${socketUrl}?account=${account_id}&authorization=${token}`
315
+ `wss://${socketUrl}?_account=${account_id}&authorization=${token}`
301
316
  );
302
317
 
303
318
  websocket.onopen = () => {
304
319
  //check if socket is connected
305
- //console.log("websocket connection established");
320
+ console.log("websocket connection established");
306
321
  };
307
322
 
308
323
  websocket.onmessage = (event) => {
@@ -318,9 +333,11 @@ const HeaderComponent = (props) => {
318
333
  props.setNewNotifications((prev) => [...prev, data.data]);
319
334
 
320
335
  //console.log(data);
321
- handleGetUnreadNotification();
322
- handleGeneralNotificationCount();
323
- handleGetNotification();
336
+ if (accountType) {
337
+ handleGetUnreadNotification(accountType);
338
+ handleGeneralNotificationCount();
339
+ handleGetNotification(accountType);
340
+ }
324
341
  }
325
342
  }
326
343
  }
@@ -336,12 +353,12 @@ const HeaderComponent = (props) => {
336
353
  // websocket for room
337
354
  useEffect(() => {
338
355
  const websocket2 = new WebSocket(
339
- `wss://${socketUrl}?account=${account_id}&authorization=${token}&room_id=${account_id}`
356
+ `wss://${socketUrl}?_account=${account_id}&authorization=${token}&room_id=${account_id}`
340
357
  );
341
358
 
342
359
  websocket2.onopen = () => {
343
360
  //check if socket is connected
344
- //console.log("room websocket connection established");
361
+ console.log("room websocket connection established");
345
362
  };
346
363
 
347
364
  websocket2.onmessage = (event) => {
@@ -361,9 +378,11 @@ const HeaderComponent = (props) => {
361
378
  if (data.event === "new.room.result") {
362
379
  //console.log(data);
363
380
  if (data.status) {
364
- handleGetUnreadNotification();
365
- handleGeneralNotificationCount();
366
- handleGetNotification();
381
+ if (accountType) {
382
+ handleGetUnreadNotification(accountType);
383
+ handleGeneralNotificationCount(accountType);
384
+ handleGetNotification(accountType);
385
+ }
367
386
  }
368
387
  }
369
388
  }
@@ -377,8 +396,10 @@ const HeaderComponent = (props) => {
377
396
  }, []);
378
397
 
379
398
  useEffect(() => {
380
- handleGetUnreadNotification();
381
- handleGeneralNotificationCount();
399
+ if (accountType) {
400
+ handleGetUnreadNotification(accountType);
401
+ handleGeneralNotificationCount(accountType);
402
+ }
382
403
  }, [notificationMarkReadData?.response]);
383
404
 
384
405
  // When Developer and on staging
@@ -40,8 +40,10 @@ const InputSection = ({
40
40
  newMessages,
41
41
  setNewMessages,
42
42
  setIsMessageSending,
43
+ accountType,
44
+ affiliates,
45
+ courseID
43
46
  }) => {
44
- const { affiliates, courseID } = useContext(MessagesContext);
45
47
  const [showEmoji, setShowEmoji] = useState();
46
48
  const [inputMethod, setInputMethod] = useState("text"); // text | recorder
47
49
  const [text, setText] = useState({
@@ -50,8 +52,6 @@ const InputSection = ({
50
52
  }); // state for user text
51
53
  const [blobData, setBlobData] = useState({}); //state for audio
52
54
  const [recording, setRecording] = useState(false);
53
- const { pathname } = useLocation();
54
- const accountType = pathname.split("/")[1]?.toLowerCase();
55
55
 
56
56
  const imageRef = useRef();
57
57
  const {
@@ -382,7 +382,8 @@ const useMessaging = () => {
382
382
 
383
383
  const handleRoomRecipientDetails = async (
384
384
  account_type,
385
- room_id,
385
+ account_id,
386
+ course_id,
386
387
  recipient_only = true
387
388
  ) => {
388
389
  try {
@@ -390,6 +391,8 @@ const useMessaging = () => {
390
391
  url: `/notify/v1/${account_type}/chats/recipient_details/`,
391
392
  params: {
392
393
  room_id,
394
+ account_id,
395
+ course_id,
393
396
  },
394
397
  });
395
398
  } catch (err) {
@@ -409,12 +412,14 @@ const useMessaging = () => {
409
412
  }
410
413
  );
411
414
 
412
- const handleRoomRecipientDetailsPersonal = async (room_id) => {
415
+ const handleRoomRecipientDetailsPersonal = async (account_id, course_id) => {
413
416
  try {
414
417
  await roomRecipientDetailsPersonal({
415
418
  url: `/notify/v1/chats/recipient_details/`,
416
419
  params: {
417
- room_id,
420
+ account_id,
421
+ course_id,
422
+ // room_id,
418
423
  },
419
424
  });
420
425
  } catch (err) {
@@ -172,25 +172,25 @@ const Messages = ({
172
172
 
173
173
  // retrieve users chats/room messages
174
174
  useEffect(() => {
175
- if (roomID) {
175
+ if (receiverID && courseID) {
176
176
  if (accountType === "enterprise") {
177
177
  handleRoomMessage(accountType, receiverID, courseID);
178
178
  handleRoomRecipientDetails(accountType, roomID);
179
179
  }
180
180
  if (!affiliates && accountType === "instructor") {
181
181
  handleRoomMessage(accountType, receiverID, courseID);
182
- handleRoomRecipientDetails(accountType, roomID);
182
+ handleRoomRecipientDetails(accountType, receiverID, courseID);
183
183
  }
184
184
  if (affiliates && accountType === "instructor") {
185
185
  handleRoomMessageAffiliate(receiverID, courseID, roomID);
186
- handleRoomRecipientDetails(accountType, roomID);
186
+ handleRoomRecipientDetails(accountType, receiverID, courseID);
187
187
  }
188
188
  if (accountType === "personal") {
189
189
  handleRetrieveMessage(receiverID, courseID, roomID);
190
- handleRoomRecipientDetailsPersonal(roomID);
190
+ handleRoomRecipientDetailsPersonal(receiverID, courseID);
191
191
  }
192
192
  }
193
- }, [roomID]);
193
+ }, [roomID, receiverID, courseID]);
194
194
 
195
195
  //console.log("allMessages", allMessages);
196
196
  //console.log("handleRoomMessage", roomMessageData);
@@ -399,6 +399,9 @@ const Messages = ({
399
399
  setLastMessage={setLastMessage}
400
400
  handleRoomMessage={handleRoomMessage}
401
401
  roomID={roomID}
402
+ accountType={accountType}
403
+ courseID={courseID}
404
+ affiliates={affiliates}
402
405
  />
403
406
  </div>
404
407
  </>