l-min-components 1.0.1192 → 1.0.1198

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.1192",
3
+ "version": "1.0.1198",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
- export const PauseIcon = ({ width, height, fill }) => (
2
+ export const PauseIcon = ({ width, height, fill, onClick }) => (
3
3
  <svg
4
4
  width={width || "20"}
5
5
  height={height || "20"}
6
6
  viewBox="0 0 20 20"
7
7
  fill="none"
8
8
  xmlns="http://www.w3.org/2000/svg"
9
+ onClick={onClick}
9
10
  >
10
11
  <path
11
12
  d="M8 7V13M12 7V13M19 10C19 14.9706 14.9706 19 10 19C5.02944 19 1 14.9706 1 10C1 5.02944 5.02944 1 10 1C14.9706 1 19 5.02944 19 10Z"
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
- export const RecorderIcon = ({ width, height, fill }) => (
2
+ export const RecorderIcon = ({ width, height, fill, onClick }) => (
3
3
  <svg
4
4
  width={width || "22"}
5
5
  height={height || "22"}
6
6
  viewBox="0 0 22 22"
7
7
  fill="none"
8
8
  xmlns="http://www.w3.org/2000/svg"
9
+ onClick={onClick}
9
10
  >
10
11
  <path
11
12
  fillRule="evenodd"
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
- export const RecorderPlayIcon = ({ width, height, fill }) => (
2
+ export const RecorderPlayIcon = ({ width, height, fill, onClick }) => (
3
3
  <svg
4
4
  width={width || "24"}
5
5
  height={height || "24"}
6
6
  viewBox="0 0 24 24"
7
7
  fill="none"
8
8
  xmlns="http://www.w3.org/2000/svg"
9
+ onClick={onClick}
9
10
  >
10
11
  <path
11
12
  d="M12 19C15.31 19 18 16.31 18 13V8C18 4.69 15.31 2 12 2C8.69 2 6 4.69 6 8V13C6 16.31 8.69 19 12 19Z"
@@ -332,6 +332,44 @@ const useHeader = () => {
332
332
  }
333
333
  };
334
334
 
335
+
336
+ const [{ ...getTotalMessagesCountData }, getTotalMessagesCount] = useAxios(
337
+ {
338
+ method: "GET",
339
+ },
340
+ {
341
+ manual: true,
342
+ }
343
+ );
344
+
345
+ const handleTotalMessagesCount = async (
346
+ account_type,
347
+ enterprise_account_id
348
+ ) => {
349
+ try {
350
+ let apiUrl;
351
+
352
+ if (account_type === "instructor") {
353
+ // For instructor account type
354
+ apiUrl = enterprise_account_id
355
+ ? `/notify/v1/instructor/${enterprise_account_id}/chats/new_messages/` // Affiliate instructor
356
+ : `/notify/v1/${account_type}/chats/new_messages/`; // Non-affiliate instructor
357
+ } else if (account_type === "enterprise") {
358
+ // For enterprise account type
359
+ apiUrl = `/notify/v1/${account_type}/chats/new_messages/`; // Enterprise
360
+ } else if (account_type === "personal") {
361
+ apiUrl = `/notify/v1/chats/new_messages/`;
362
+ } else {
363
+ }
364
+ await getTotalMessagesCount({
365
+ url: apiUrl,
366
+ });
367
+ } catch (err) {
368
+ console.log(err);
369
+ }
370
+ };
371
+
372
+
335
373
  return {
336
374
  handleGetUserDetails,
337
375
  userDetails,
@@ -46,7 +46,7 @@ const InputSection = ({
46
46
  handleCreateMessage,
47
47
  createMessageData,
48
48
  enterpriseAffiliateID,
49
- receiverID
49
+ receiverID,
50
50
  }) => {
51
51
  const [showEmoji, setShowEmoji] = useState();
52
52
  const [inputMethod, setInputMethod] = useState("text"); // text | recorder
@@ -56,11 +56,11 @@ const InputSection = ({
56
56
  }); // state for user text
57
57
  const [blobData, setBlobData] = useState({}); //state for audio
58
58
  const [recording, setRecording] = useState(false);
59
+ const [isPlaying, setIsPlaying] = useState(false);
59
60
  const [successResponse, setSuccessResponse] = useState(false);
60
61
 
61
62
  const imageRef = useRef();
62
63
  const {
63
-
64
64
  handleCreateMessageWithMedia,
65
65
  createMessageWithMediaData,
66
66
  createMessageAffiliateData,
@@ -89,7 +89,14 @@ const InputSection = ({
89
89
  const data = {
90
90
  media: file,
91
91
  };
92
- handleCreateMessageWithMedia(data.media, receiverID);
92
+ // handleCreateMessageWithMedia(data.media, receiverID);
93
+ handleCreateMessageWithMedia(
94
+ receiverID,
95
+ accountType,
96
+ data.media,
97
+ courseID,
98
+ enterpriseAffiliateID
99
+ );
93
100
  setInputMethod("text");
94
101
  //console.log("uploas", file);
95
102
  }
@@ -99,7 +106,13 @@ const InputSection = ({
99
106
  setIsMessageSending(true);
100
107
 
101
108
  setTimeout(() => {
102
- handleCreateMessage(receiverID, accountType, text, courseID, enterpriseAffiliateID);
109
+ handleCreateMessage(
110
+ receiverID,
111
+ accountType,
112
+ text,
113
+ courseID,
114
+ enterpriseAffiliateID
115
+ );
103
116
  }, 1000);
104
117
  }
105
118
  };
@@ -232,6 +245,8 @@ const InputSection = ({
232
245
  setBlobData,
233
246
  recording,
234
247
  setRecording,
248
+ isPlaying,
249
+ setIsPlaying,
235
250
  }}
236
251
  />
237
252
  </>
@@ -267,26 +282,41 @@ const Recorder = ({
267
282
  setInputMethod,
268
283
  recording,
269
284
  setRecording,
285
+ isPlaying,
286
+ setIsPlaying,
270
287
  }) => {
271
288
  const [recordingTime, setRecordingTime] = useState(0);
272
289
  const waveSurfer = useRef(null);
273
290
  const counterRef = useRef();
291
+ const [pausedTime, setPausedTime] = useState(0);
292
+
293
+ console.log("blob", blobData);
294
+
295
+ // Reset everything when clicking Bin
296
+ const clearRecording = () => {
297
+ if (waveSurfer.current) {
298
+ waveSurfer.current.stop();
299
+ waveSurfer.current.empty();
300
+ }
301
+
302
+ setBlobData({ blob: null, url: null });
303
+ setRecording(false);
304
+ setIsPlaying(false);
305
+ setRecordingTime(0);
306
+ setPausedTime(0);
307
+ setInputMethod("text");
308
+ };
274
309
 
275
- //console.log("blob", blobData);
276
- // on record stop, concatenate blob to form a pause and continue recording feature
310
+ // Concatenate blobs for pause & continue recording
277
311
  const handleStop = (data) => {
278
312
  const { blob } = data;
279
- setBlobData((state) => {
280
- const newBlob = state.blob
281
- ? new Blob([state.blob, blob], { type: "audio/wav" })
313
+ setBlobData((prevState) => {
314
+ const newBlob = prevState.blob
315
+ ? new Blob([prevState.blob, blob], { type: "audio/wav" })
282
316
  : blob;
283
317
 
284
318
  const url = URL.createObjectURL(newBlob);
285
-
286
- return {
287
- blob: newBlob,
288
- url,
289
- };
319
+ return { blob: newBlob, url };
290
320
  });
291
321
  };
292
322
 
@@ -294,32 +324,28 @@ const Recorder = ({
294
324
  setRecording(true);
295
325
  }, []);
296
326
 
297
- // handle counting time while recording
327
+ // Handle recording time counter
298
328
  useEffect(() => {
299
- let time = 0;
300
329
  if (recording) {
330
+ let time = pausedTime;
301
331
  counterRef.current = setInterval(() => {
302
332
  time++;
303
- const currentDuration = waveSurfer.current?.getDuration() ?? 0;
304
- // //console.log(waveSurfer.current?.getDuration() ?? 0);
305
- setRecordingTime(() => {
306
- return Math.floor(currentDuration + time);
307
- });
333
+ setRecordingTime(time);
308
334
  }, 1000);
335
+ } else {
336
+ clearInterval(counterRef.current);
337
+ setPausedTime(recordingTime);
309
338
  }
310
- return () => {
311
- if (counterRef.current) {
312
- clearInterval(counterRef.current);
313
- }
314
- };
339
+
340
+ return () => clearInterval(counterRef.current);
315
341
  }, [recording]);
316
342
 
317
- //handle creating waves each time
343
+ // Setup WaveSurfer for playback
318
344
  useEffect(() => {
319
345
  if (blobData.blob) {
320
346
  if (!waveSurfer.current) {
321
347
  waveSurfer.current = WaveSurfer.create({
322
- container: "#waves",
348
+ container: "#waves-input",
323
349
  waveColor: "#E5AD0E",
324
350
  progressColor: "#FECF4C",
325
351
  cursorWidth: 0,
@@ -331,6 +357,7 @@ const Recorder = ({
331
357
  });
332
358
  }
333
359
 
360
+ waveSurfer.current.on("finish", () => setIsPlaying(false));
334
361
  waveSurfer.current.loadBlob(blobData.blob);
335
362
  }
336
363
  }, [blobData.blob]);
@@ -338,33 +365,53 @@ const Recorder = ({
338
365
  return (
339
366
  <>
340
367
  <div className="left-recorder-state">
341
- <span className="icon" onClick={(e) => setRecording((state) => !state)}>
342
- {recording ? <PauseIcon /> : <RecorderIcon />}
368
+ <span className="icon">
369
+ {(recording || isPlaying) && (
370
+ <PauseIcon
371
+ onClick={() => {
372
+ if (recording) {
373
+ setRecording(false); // Stop recording
374
+ } else if (isPlaying) {
375
+ waveSurfer.current.pause(); // Pause playback
376
+ setIsPlaying(false);
377
+ }
378
+ }}
379
+ />
380
+ )}
381
+
382
+ {!recording && !isPlaying && blobData.blob && (
383
+ <RecorderIcon
384
+ onClick={() => {
385
+ waveSurfer.current.play(); // Play recording
386
+ setIsPlaying(true);
387
+ }}
388
+ />
389
+ )}
343
390
  </span>
391
+
344
392
  <div className="timer">
345
393
  {moment.duration(recordingTime, "seconds").minutes()}:
346
394
  {moment.duration(recordingTime, "seconds").seconds()}
347
395
  </div>
348
396
  </div>
397
+
349
398
  <div className="waves-section">
350
- {!recording && (
399
+ {!recording && blobData.blob && (
351
400
  <span
352
401
  className="icon"
353
402
  onClick={() => {
354
- waveSurfer.current.playPause();
403
+ waveSurfer.current.stop(); // Stop playback
404
+ setIsPlaying(false);
405
+ setRecording(true); // Resume recording
355
406
  }}
356
407
  >
357
408
  <RecorderPlayIcon />
358
409
  </span>
359
410
  )}
360
- <div id="waves"></div>
361
- {!recording && (
362
- <span
363
- className="icon"
364
- onClick={
365
- () => setInputMethod("text") // resetting input method, everything about recorder shutdown
366
- }
367
- >
411
+ <div id="waves-input"></div>
412
+
413
+ {!recording && blobData.blob && (
414
+ <span className="icon" onClick={clearRecording}>
368
415
  <Bin />
369
416
  </span>
370
417
  )}
@@ -43,14 +43,18 @@ const useMedia = () => {
43
43
  const [{ ...uploadMediaData }, uploadMedia] = useAxios(
44
44
  {
45
45
  method: "POST",
46
- url: `/media/v1/enterprise/files/`,
46
+ // url: `/media/v1/enterprise/files/`,
47
47
  },
48
48
  {
49
49
  manual: true,
50
50
  }
51
51
  );
52
52
 
53
- const handleUploadMedia = async (files) => {
53
+ const handleUploadMedia = async (
54
+ files,
55
+ account_type,
56
+ enterprise_account_id
57
+ ) => {
54
58
  try {
55
59
  if (files) {
56
60
  console.log(files);
@@ -59,7 +63,25 @@ const useMedia = () => {
59
63
  // const formdata = new FormData();
60
64
  // formdata.append("upload", files.upload);
61
65
  // return await uploadMedia({ data: formdata });
62
- return await uploadMedia({ data: files });
66
+ let apiUrl;
67
+
68
+ if (account_type === "instructor") {
69
+ // For instructor account type
70
+ apiUrl = enterprise_account_id
71
+ ? `/media/v1/instructor/${enterprise_account_id}/files/` // Affiliate instructor
72
+ : `/media/v1/${account_type}/files/`; // Non-affiliate instructor
73
+ } else if (account_type === "enterprise") {
74
+ // For enterprise account type
75
+ apiUrl = `/media/v1/${account_type}/files/`; // Enterprise
76
+ } else if (account_type === "personal") {
77
+ // For personal account type
78
+ apiUrl = `/media/v1/files/`;
79
+ } else {
80
+ // throw new Error("Invalid account type"); // Optional error handling for unexpected types
81
+ console.log("Invalid account type");
82
+ }
83
+
84
+ return await uploadMedia({ url: apiUrl, data: files });
63
85
  } else {
64
86
  return false;
65
87
  }
@@ -67,7 +89,6 @@ const useMedia = () => {
67
89
  console.log(err);
68
90
  }
69
91
  };
70
-
71
92
  return {
72
93
  getMediaFilesData,
73
94
  handleGetMediaFiles,
@@ -103,7 +103,7 @@ const useMessaging = () => {
103
103
 
104
104
  if (account_type === "instructor") {
105
105
  // For instructor account type
106
- apiUrl = affiliates
106
+ apiUrl = enterprise_account_id
107
107
  ? `/notify/v1/instructor/${enterprise_account_id}/chats/` // Affiliate instructor
108
108
  : `/notify/v1/${account_type}/chats/`; // Non-affiliate instructor
109
109
  } else if (account_type === "enterprise") {
@@ -130,7 +130,6 @@ const useMessaging = () => {
130
130
  });
131
131
  };
132
132
 
133
-
134
133
  //POST Create message Affiliate
135
134
  const [{ ...createMessageAffiliateData }, createMessageAffiliate] = useAxios(
136
135
  {
@@ -170,19 +169,42 @@ const useMessaging = () => {
170
169
  }
171
170
  );
172
171
 
173
- const handleCreateMessageWithMedia = async (file, account_id) => {
172
+ const handleCreateMessageWithMedia = async (
173
+ account_id,
174
+ account_type,
175
+ file,
176
+ course_id,
177
+ enterprise_account_id
178
+ ) => {
174
179
  setLoading(true);
175
180
  const newUploaded = [];
176
181
 
177
182
  const formData = new FormData();
178
183
  formData.append("upload", file);
179
- const uploadedData = await handleUploadMedia(formData);
184
+ const uploadedData = await handleUploadMedia(formData, account_type, enterprise_account_id);
180
185
 
181
186
  newUploaded.push(uploadedData?.data?.results[0]);
182
187
 
188
+ let apiUrl;
189
+
190
+ if (account_type === "instructor") {
191
+ // For instructor account type
192
+ apiUrl = enterprise_account_id
193
+ ? `/notify/v1/instructor/${enterprise_account_id}/chats/` // Affiliate instructor
194
+ : `/notify/v1/${account_type}/chats/`; // Non-affiliate instructor
195
+ } else if (account_type === "enterprise") {
196
+ // For enterprise account type
197
+ apiUrl = `/notify/v1/${account_type}/chats/`; // Enterprise
198
+ } else if (account_type === "personal") {
199
+ // For personal account type
200
+ apiUrl = `/notify/v1/chats/`;
201
+ } else {
202
+ console.log("Invalid account type");
203
+ }
204
+
183
205
  // if (uploadMediaData?.data) {
184
206
  await createMessageMedia({
185
- url: `/notify/v1/chats/`,
207
+ url: apiUrl,
186
208
  data: {
187
209
  // ...data,
188
210
  ...(newUploaded?.length && {
@@ -191,6 +213,7 @@ const useMessaging = () => {
191
213
  },
192
214
  params: {
193
215
  account_id,
216
+ course_id,
194
217
  },
195
218
  });
196
219
  // }
@@ -244,12 +267,13 @@ const useMessaging = () => {
244
267
  account_id,
245
268
  course_id,
246
269
  room_id,
270
+ enterprise_account_id,
247
271
  limit,
248
272
  offset
249
273
  ) => {
250
274
  try {
251
275
  await roomMessageAffiliate({
252
- url: `/notify/v1/instructor/${account_id}/chats/`,
276
+ url: `/notify/v1/instructor/${enterprise_account_id}/chats/`,
253
277
  params: {
254
278
  account_id,
255
279
  course_id,
@@ -326,11 +326,25 @@ const useRooms = () => {
326
326
  account_type,
327
327
  account_id,
328
328
  course_id,
329
- data
329
+ data,
330
+ enterprise_account_id
330
331
  ) => {
331
332
  try {
333
+ let apiUrl;
334
+
335
+ if (account_type === "instructor") {
336
+ apiUrl = enterprise_account_id
337
+ ? `/notify/v1/instructor/${enterprise_account_id}/rooms/chat_course/` // Affiliate instructor
338
+ : `/notify/v1/${account_type}/rooms/chat_course/`; // Non-affiliate instructor
339
+ } else if (account_type === "enterprise") {
340
+ apiUrl = `/notify/v1/${account_type}/rooms/chat_course/`; // Enterprise
341
+ } else if (account_type === "personal") {
342
+ apiUrl = `/notify/v1/rooms/chat_course/`; // For personal account type
343
+ } else {
344
+ console.log("Invalid account type");
345
+ }
332
346
  await createRoom({
333
- url: `/notify/v1/${account_type}/rooms/chat_course/`,
347
+ url: apiUrl,
334
348
  data: {
335
349
  ...data,
336
350
  },
@@ -793,7 +793,6 @@ export const MessageBox = styled.div`
793
793
  h6 {
794
794
  font-size: 14px;
795
795
  font-weight: 400;
796
- color: #ffffff;
797
796
  /* padding-top: 6px; */
798
797
  }
799
798
 
@@ -957,6 +956,12 @@ export const TextMessagePanel = styled.div`
957
956
  max-height: 58px;
958
957
  display: block;
959
958
  }
959
+ #waves-input {
960
+ /* min-width: 500px; */
961
+ width: 100%;
962
+ max-height: 58px;
963
+ display: block;
964
+ }
960
965
  .react-mic {
961
966
  opacity: 0;
962
967
  pointer-events: none;
@@ -45,24 +45,21 @@ const MessageBubble = ({
45
45
  </div>
46
46
  ) : (
47
47
  <>
48
- {chat?.media?.mimetype === "audio/wav" ? (
49
- <div
50
- className={
51
- chat?.user_message ? "user-audio" : "friend-audio"
52
- }>
53
- <WaveSurferPlayer audio={chat?.media?.url} />
54
- <p className="msg-time-stamp">
55
- {moment(chat?.media?.created_at).format("h:mm a")}
56
- </p>
57
- </div>
58
- ) : (
59
- <div className={chat?.user_message ? "user-img" : "friend-img"}>
60
- <img src={chat?.media?.stream_url} />
61
- <p className="msg-time-stamp">
62
- {moment(chat?.created_at).format("h:mm a")}
63
- </p>
64
- </div>
65
- )}
48
+ <div
49
+ className={chat?.user_message ? "user-audio" : "friend-audio"}
50
+ >
51
+ <WaveSurferPlayer streamSrc={chat?.media?.url} />
52
+ {/* <StreamAudioPlayer streamSrc={chat?.media?.url} /> */}
53
+ {/* <WaveSurferPlayer
54
+ height={100}
55
+ waveColor="rgb(200, 0, 200)"
56
+ progressColor="rgb(100, 0, 100)"
57
+ url={chat?.media?.url}
58
+ /> */}
59
+ <p className="msg-time-stamp">
60
+ {moment(chat?.media?.created_at).format("h:mm a")}
61
+ </p>
62
+ </div>
66
63
  </>
67
64
  )}
68
65
  </div>
@@ -1,64 +1,154 @@
1
- import React, { useEffect, useRef, useState, useCallback } from "react";
1
+ import React, {
2
+ useEffect,
3
+ useRef,
4
+ useState,
5
+ useCallback,
6
+ useContext,
7
+ } from "react";
2
8
  import WaveSurfer from "wavesurfer.js";
3
9
  import { FaPlayCircle, FaPauseCircle } from "react-icons/fa";
4
- import styled from "styled-components";
10
+ import useAudioPlayer from "../../../useAudioPlayer";
11
+ import AudioWaveComponent from "../../../useAudioPlayer/audioWave";
5
12
 
6
- const WaveSurferPlayer = ({ audio }) => {
7
- const containerRef = useRef();
8
- const waveSurferRef = useRef();
13
+ const WaveSurferPlayer = ({ size, streamSrc }) => {
14
+ const { isPlaying, progress, play, pause } = useAudioPlayer({
15
+ streamSrc,
16
+ });
17
+ // const containerRef = useRef();
18
+ // const waveSurferRef = useRef();
19
+ // const hlsRef = useRef();
9
20
  // const waveSurferRef = useRef({
10
21
  // isPlaying: () => false,
11
22
  // })
12
- const [isPlaying, toggleIsPlaying] = useState(false);
23
+ // const [isPlaying, toggleIsPlaying] = useState(false);
24
+ // const { accessToken } = useContext(OutletContext);
25
+ // const account_id = getCookie("defaultAccountID");
13
26
 
14
- useEffect(() => {
15
- waveSurferRef.current = WaveSurfer.create({
16
- // container: "#waves",
17
- container: containerRef.current,
18
- responsive: true,
19
- barWidth: 2,
20
- barHeight: 10,
21
- waveColor: "#E5AD0E",
22
- progressColor: "#FECF4C",
23
- cursorWidth: 0,
24
- height: 30,
25
- barGap: 2,
26
- barRadius: 2,
27
- barMinHeight: 3,
28
- });
29
- waveSurferRef.current.load(audio);
27
+ // useEffect(() => {
28
+ // if (!src) {
29
+ // hlsRef.current = new Hls({
30
+ // xhrSetup: function (xhr, url) {
31
+ // try {
32
+ // const modifiedURL = `${url}?_account=${account_id}`;
33
+ // xhr.open("GET", modifiedURL, true);
34
+ // xhr.setRequestHeader("Authorization", `Bearer ${accessToken}`);
35
+ // } catch (error) {
36
+ // console.error("XHR setup error:", error);
37
+ // }
38
+ // },
39
+ // });
40
+ // }
30
41
 
31
- return () => {
32
- waveSurferRef.current.destroy();
33
- };
34
- }, [audio]);
42
+ // waveSurferRef.current = WaveSurfer.create({
43
+ // // container: "#waves",
44
+ // container: containerRef.current,
45
+ // responsive: true,
46
+ // barWidth: 2,
47
+ // barHeight: 10,
48
+ // waveColor: "#fff",
49
+ // progressColor: "#fff",
50
+ // cursorWidth: 0,
51
+ // height: 30,
52
+ // barGap: 2,
53
+ // barRadius: 2,
54
+ // barMinHeight: 3,
55
+ // });
56
+ // // waveSurferRef.current.load(audio);
57
+ // // waveSurferRef.current.on("ready", (e) => {
58
+ // // waveSurferRef.current = waveSurfer;
59
+
60
+ // // console.log("wave", e);
61
+ // // });
62
+
63
+ // //stream test
64
+
65
+ // if (Hls?.isSupported() && !src) {
66
+ // hlsRef.current.attachMedia(waveSurferRef?.current?.media);
67
+ // hlsRef.current.loadSource(
68
+ // "https://dev-117782726-api.learngual.com" + audio
69
+ // );
70
+ // hlsRef.current.startLoad();
71
+ // } else {
72
+ // waveSurferRef.current.load(src);
73
+ // }
74
+
75
+ // waveSurferRef.current.on("finish", () => {
76
+ // toggleIsPlaying(false);
77
+ // });
78
+ // //stream test
79
+
80
+ // return () => {
81
+ // // waveSurferRef.current.destroy();
82
+ // if (hlsRef.current) {
83
+ // hlsRef.current.destroy();
84
+ // }
85
+ // if (waveSurferRef.current) {
86
+ // waveSurferRef.current.destroy();
87
+ // }
88
+ // };
89
+ // }, [audio]);
90
+
91
+ // const [waveSurfer, setWaveSurfer] = useState(null);
92
+
93
+ // useEffect(() => {
94
+ // // Initialize WaveSurfer
95
+ // const wavesurfer = WaveSurfer.create({
96
+ // container: '#waves', // The ID of the container element
97
+ // waveColor: 'violet',
98
+ // progressColor: 'purple'
99
+ // });
100
+ // setWaveSurfer(wavesurfer);
101
+
102
+ // // Cleanup on component unmount
103
+ // return () => wavesurfer.destroy();
104
+ // }, []);
105
+
106
+ // const loadAudio = async (audio) => {
107
+ // try {
108
+ // const response = await fetch(audio);
109
+ // const audioBlob = await response.blob();
110
+ // waveSurfer.loadBlob(audioBlob);
111
+ // console.log(response)
112
+ // } catch (error) {
113
+ // console.error('Error loading audio:', error);
114
+ // }
115
+ // };
116
+ console.log("wave", isPlaying);
35
117
 
36
- //console.log("wave", isPlaying);
37
118
  return (
38
119
  <div style={{ display: "flex", alignItems: "center", height: "33px" }}>
39
120
  <button
40
121
  onClick={() => {
41
- waveSurferRef.current.playPause();
42
- toggleIsPlaying(waveSurferRef.current.isPlaying());
122
+
123
+ // waveSurferRef.current.playPause();
124
+ // toggleIsPlaying(waveSurferRef.current.isPlaying());
125
+ // waveSurferRef.current.play();
126
+ // loadAudio(audio)
127
+ // toggleIsPlaying(waveSurferRef.current.isPlaying());
128
+ // waveSurferRef.current.isPlaying()
129
+ // ? waveSurferRef.current.pause()
130
+ // : waveSurferRef.current.play();
43
131
  }}
44
132
  type="button"
45
- className="audio-btn">
133
+ className="audio-btn"
134
+ >
46
135
  {isPlaying ? (
47
- <FaPauseCircle size="20px" style={{ color: "#FEBF10" }} />
136
+ <FaPauseCircle
137
+ size="20px"
138
+ style={{ color: "#fff" }}
139
+ onClick={pause}
140
+ />
48
141
  ) : (
49
- <FaPlayCircle size="20px" style={{ color: "#FEBF10" }} />
142
+ <FaPlayCircle size="20px" style={{ color: "#fff" }} onClick={play} />
50
143
  )}
51
144
  </button>
52
- <div
53
- ref={containerRef}
54
- style={{
55
- width: "100%",
56
- display: "block",
57
- height: 30,
58
- }}>
59
- {" "}
145
+ <div id="waves-bubble">
146
+ <AudioWaveComponent
147
+ type="small"
148
+ count={14}
149
+ playState={isPlaying ? "play" : "paused"}
150
+ />
60
151
  </div>
61
- <div id="waves"></div>
62
152
  </div>
63
153
  );
64
154
  };
@@ -196,7 +196,7 @@ const Messages = ({
196
196
  handleRoomRecipientDetails(accountType, receiverID, courseID);
197
197
  }
198
198
  if (affiliates && accountType === "instructor") {
199
- handleRoomMessageAffiliate(receiverID, courseID, roomID);
199
+ handleRoomMessageAffiliate(receiverID, courseID, roomID, enterpriseAffiliateID);
200
200
  handleRoomRecipientDetailsAffiliate(enterpriseAffiliateID, receiverID, courseID); //check later
201
201
  // handleRoomRecipientDetails(accountType, receiverID, courseID);
202
202
  }
@@ -213,7 +213,7 @@ const Messages = ({
213
213
  }, [receiverID, courseID, roomID]);
214
214
 
215
215
  useEffect(() => {
216
- if (createMessageData?.data) {
216
+ if (createMessageData?.data || createMessageWithMediaData?.data) {
217
217
  if (accountType === "enterprise") {
218
218
  handleRoomMessage(accountType, receiverID, courseID);
219
219
  handleRoomRecipientDetails(accountType, receiverID, courseID);
@@ -223,15 +223,15 @@ const Messages = ({
223
223
  handleRoomRecipientDetails(accountType, receiverID, courseID);
224
224
  }
225
225
  if (affiliates && accountType === "instructor") {
226
- handleRoomMessageAffiliate(receiverID, courseID, roomID);
227
- handleRoomRecipientDetails(accountType, receiverID, courseID);
226
+ handleRoomMessageAffiliate(receiverID, courseID, roomID, enterpriseAffiliateID);
227
+ handleRoomRecipientDetailsAffiliate(enterpriseAffiliateID, receiverID, courseID); //
228
228
  }
229
229
  if (accountType === "personal") {
230
230
  handleRetrieveMessage(receiverID, courseID, roomID);
231
231
  handleRoomRecipientDetailsPersonal(receiverID, courseID);
232
232
  }
233
233
  }
234
- }, [createMessageData?.data]);
234
+ }, [createMessageData?.data, createMessageWithMediaData?.data]);
235
235
 
236
236
  //console.log("allMessages", allMessages);
237
237
  //console.log("handleRoomMessage", roomMessageData);
@@ -149,6 +149,7 @@ export const sideMenuOptions = [
149
149
  icon: <MessagesIcon />,
150
150
  iconActive: <MessagesIconActive />,
151
151
  text: "Messages",
152
+ notifications: true,
152
153
  },
153
154
  {
154
155
  path: "/enterprise/announcements",
@@ -196,6 +197,7 @@ export const sideMenuOptions = [
196
197
  icon: <MessagesIcon />,
197
198
  iconActive: <MessagesIconActive />,
198
199
  text: "Messages",
200
+ notifications: true,
199
201
  },
200
202
  {
201
203
  path: "/instructor/announcements",
@@ -250,6 +252,7 @@ export const sideMenuOptions = [
250
252
  icon: <MessagesIcon />,
251
253
  iconActive: <MessagesIconActive />,
252
254
  text: "Messages",
255
+ notifications: true,
253
256
  },
254
257
  {
255
258
  path: "/personal/addons",