l-min-components 1.0.1002 → 1.0.1008

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.1008",
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,7 @@ 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
+ const [successResponse, setSuccessResponse] = useState(false);
55
56
 
56
57
  const imageRef = useRef();
57
58
  const {
@@ -59,6 +60,7 @@ const InputSection = ({
59
60
  createMessageData,
60
61
  handleCreateMessageWithMedia,
61
62
  createMessageWithMediaData,
63
+ createMessageAffiliateData,
62
64
  handleCreateMessageAffiliate,
63
65
  createMessagePersonalData,
64
66
  handleCreateMessagePersonal,
@@ -138,7 +140,30 @@ const InputSection = ({
138
140
  text: "",
139
141
  });
140
142
  }
141
- }, [createMessageData?.response]);
143
+ if (createMessageAffiliateData?.response?.status === 201) {
144
+ setNewMessages((prev) => [...prev, createMessageAffiliateData?.data]);
145
+ // newMessages[newMessages.length - 1] = createMessageData?.data;
146
+ setIsMessageSending(false);
147
+ setText({
148
+ ...text,
149
+ text: "",
150
+ });
151
+ }
152
+
153
+ if (createMessagePersonalData?.response?.status === 201) {
154
+ setNewMessages((prev) => [...prev, createMessagePersonalData?.data]);
155
+ // newMessages[newMessages.length - 1] = createMessageData?.data;
156
+ setIsMessageSending(false);
157
+ setText({
158
+ ...text,
159
+ text: "",
160
+ });
161
+ }
162
+ }, [
163
+ createMessageData?.response,
164
+ createMessageAffiliateData?.response,
165
+ createMessagePersonalData?.response,
166
+ ]);
142
167
 
143
168
  useEffect(() => {
144
169
  if (createMessageWithMediaData?.response?.status === 201) {
@@ -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) {
@@ -5,6 +5,7 @@ import Avatar from "../../assets/images/avatar.jpg";
5
5
  import { HiUser, HiOfficeBuilding } from "react-icons/hi";
6
6
  import { FiMoreVertical } from "react-icons/fi";
7
7
  import MoreSvg from "../assets/more";
8
+ import { useNavigate } from "react-router-dom";
8
9
 
9
10
  /** The top green header of an open chat
10
11
  *
@@ -19,11 +20,13 @@ const ChatHeader = ({
19
20
  deleteChatModal,
20
21
  userFullName,
21
22
  courseName,
23
+ accountType,
22
24
  userType,
23
25
  userAvatar,
24
26
  }) => {
25
27
  // handle click outside dropdown container
26
28
  const dropdownContainer = useRef(null);
29
+ const navigate = useNavigate()
27
30
  const handleClickOutside = (event) => {
28
31
  if (
29
32
  dropdownContainer.current &&
@@ -100,7 +103,7 @@ const ChatHeader = ({
100
103
  : "Unpin chat"
101
104
  : "Pin chat"}
102
105
  </li>
103
- <li onClick={openModal}> Report User</li>
106
+ <li onClick={() => navigate(`/msg/${accountType}/messages`)}> Report User</li>
104
107
  <li onClick={deleteChatModal}> Delete chat</li>
105
108
  </ul>
106
109
  </div>
@@ -50,7 +50,7 @@ const Messages = ({
50
50
  receiverID,
51
51
  setReceiverID,
52
52
  accountType,
53
- affiliates = false
53
+ affiliates = false,
54
54
  }) => {
55
55
  const [showEmoji, setShowEmoji] = useState(false);
56
56
  const [chatOptions, setChatOptions] = useState(false);
@@ -99,6 +99,7 @@ const Messages = ({
99
99
  handleRoomMessageRecipient,
100
100
  roomRecipientDetailsData,
101
101
  handleRoomRecipientDetails,
102
+ retrieveMessageData,
102
103
  handleRetrieveMessage,
103
104
  roomMessageAffiliateData,
104
105
  handleRoomMessageAffiliate,
@@ -129,10 +130,21 @@ const Messages = ({
129
130
 
130
131
  // use effects for successful responses***
131
132
  useEffect(() => {
132
- if (roomMessageData?.response?.status === 200)
133
+ if (roomMessageData?.response?.status === 200) {
133
134
  setAllMessages(roomMessageData?.data?.results?.reverse());
135
+ }
136
+ if (roomMessageAffiliateData?.response?.status === 200) {
137
+ setAllMessages(roomMessageAffiliateData?.data?.results?.reverse());
138
+ }
139
+ if (retrieveMessageData?.response?.status === 200) {
140
+ setAllMessages(retrieveMessageData?.data?.results?.reverse());
141
+ }
134
142
  setNewMessages([]);
135
- }, [roomMessageData?.response]);
143
+ }, [
144
+ roomMessageData?.response,
145
+ roomMessageAffiliateData?.response,
146
+ retrieveMessageData?.response,
147
+ ]);
136
148
 
137
149
  // useEffect(() => {
138
150
  // if (changePinStatusData?.response?.status === 202) handleGetMyRooms();
@@ -145,7 +157,6 @@ const Messages = ({
145
157
  location.reload();
146
158
 
147
159
  // toast.success("Chat deleted successfully");
148
-
149
160
  }
150
161
  }, [clearChatData?.response]);
151
162
 
@@ -172,25 +183,25 @@ const Messages = ({
172
183
 
173
184
  // retrieve users chats/room messages
174
185
  useEffect(() => {
175
- if (roomID) {
186
+ if (receiverID && courseID) {
176
187
  if (accountType === "enterprise") {
177
188
  handleRoomMessage(accountType, receiverID, courseID);
178
- handleRoomRecipientDetails(accountType, roomID);
189
+ handleRoomRecipientDetails(accountType, receiverID, courseID);
179
190
  }
180
191
  if (!affiliates && accountType === "instructor") {
181
192
  handleRoomMessage(accountType, receiverID, courseID);
182
- handleRoomRecipientDetails(accountType, roomID);
193
+ handleRoomRecipientDetails(accountType, receiverID, courseID);
183
194
  }
184
195
  if (affiliates && accountType === "instructor") {
185
196
  handleRoomMessageAffiliate(receiverID, courseID, roomID);
186
- handleRoomRecipientDetails(accountType, roomID);
197
+ handleRoomRecipientDetails(accountType, receiverID, courseID);
187
198
  }
188
199
  if (accountType === "personal") {
189
200
  handleRetrieveMessage(receiverID, courseID, roomID);
190
- handleRoomRecipientDetailsPersonal(roomID);
201
+ handleRoomRecipientDetailsPersonal(receiverID, courseID);
191
202
  }
192
203
  }
193
- }, [roomID]);
204
+ }, [roomID, receiverID, courseID]);
194
205
 
195
206
  //console.log("allMessages", allMessages);
196
207
  //console.log("handleRoomMessage", roomMessageData);
@@ -323,21 +334,12 @@ const Messages = ({
323
334
  userType={userType}
324
335
  courseName={courseName}
325
336
  userAvatar={userAvatar}
337
+ accountType={accountType}
326
338
  />
327
339
 
328
340
  <MessageBody ref={scrollRef}>
329
- {roomMessageData?.loading && (
330
- <div className="loader-box">
331
- <Loader
332
- zoom={0.3}
333
- color="#E5E5E5"
334
- style={{ textAlign: "center" }}
335
- />
336
- </div>
337
- )}
338
- {roomMessageData?.data?.results?.length > 0 &&
339
- !roomMessageData?.loading &&
340
- !roomMessageData?.error ? (
341
+ {roomMessageData?.loading && <></>}
342
+ {allMessages.length > 0 ? (
341
343
  <>
342
344
  {allMessages?.map((chat, idx) => (
343
345
  <>
@@ -399,6 +401,9 @@ const Messages = ({
399
401
  setLastMessage={setLastMessage}
400
402
  handleRoomMessage={handleRoomMessage}
401
403
  roomID={roomID}
404
+ accountType={accountType}
405
+ courseID={courseID}
406
+ affiliates={affiliates}
402
407
  />
403
408
  </div>
404
409
  </>