@esvndev/es-react-template-chat 0.0.97 → 0.0.98

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/dist/index.mjs CHANGED
@@ -91728,7 +91728,6 @@ const IconFileTypeColor = (props) => {
91728
91728
  return jsx("img", { ...props, src: icon, style: { width: width ? width : 24, height: height ? height : 'auto', ...props.style } });
91729
91729
  };
91730
91730
 
91731
- const MySwal$1 = withReactContent(Swal);
91732
91731
  const DateHeader = memo(({ label }) => (jsx("div", { className: "d-flex justify-content-center", children: jsx("div", { style: {
91733
91732
  backgroundColor: "rgba(0,0,0,0.2)",
91734
91733
  padding: "2px 15px",
@@ -92462,7 +92461,7 @@ const ChatLog = (props) => {
92462
92461
  backgroundImage: `url(${`${CDN_URL_VIEW}/${replyData?.path[0].path.trim()}`})`
92463
92462
  } })), replyData?.type === "file" && (jsx("div", { style: { marginRight: 8 }, children: jsx(IconFileTypeColor, { fileType: replyData?.path?.[0]?.type, width: 35 }) })), jsxs("div", { className: "reply-content d-flex flex-column", children: [jsx("div", { className: "fw-bold", children: replyData?.createdByName }), jsx("div", { children: renderMessageReply(replyData?.type, replyData?.msg) })] })] }) }));
92464
92463
  }, [renderMessageReply]);
92465
- const downloadFile = useCallback(async (path) => {
92464
+ useCallback(async (path) => {
92466
92465
  const url = `${CDN_URL_VIEW}/${path}`;
92467
92466
  try {
92468
92467
  const response = await axios$1.get(url, { responseType: "blob" });
@@ -92479,111 +92478,107 @@ const ChatLog = (props) => {
92479
92478
  console.error(error);
92480
92479
  }
92481
92480
  }, []);
92482
- const handleDownloadClick = useCallback((param) => {
92483
- // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
92484
- const targetFile = clickedImageFile || param?.path?.[0];
92485
- if (targetFile?.path) {
92486
- downloadFile(targetFile.path);
92487
- }
92488
- else {
92489
- console.error("No valid path found in param");
92490
- }
92491
- }, [clickedImageFile, downloadFile]);
92492
- const handleDelete = useCallback(async (param) => {
92493
- try {
92494
- const result = await MySwal$1.fire({
92495
- title: "Xác nhận",
92496
- html: "Tin nhắn sẽ bị xóa vĩnh viễn. <br> Bạn có chắc muốn xóa?",
92497
- allowOutsideClick: false,
92498
- showCancelButton: true,
92499
- confirmButtonText: "Xoá",
92500
- cancelButtonText: "Hủy",
92501
- customClass: {
92502
- confirmButton: "btn btn-primary",
92503
- cancelButton: "btn btn-danger ms-1"
92504
- },
92505
- buttonsStyling: false
92506
- });
92507
- if (result.value) {
92508
- const data = { id: param.id, chatRoomId: groupChatUsers.id };
92509
- await deleteMessageApi(data);
92510
- }
92511
- else if (result.dismiss === MySwal$1.DismissReason.cancel) {
92512
- console.log("Hủy xóa tin nhắn");
92513
- }
92514
- }
92515
- catch (error) {
92516
- console.error("Error deleting message:", error);
92517
- }
92518
- }, [deleteMessageApi, groupChatUsers?.id]);
92519
- const handleRecall = useCallback(async (param) => {
92520
- try {
92521
- const result = await MySwal$1.fire({
92522
- title: "Xác nhận",
92523
- html: "Bạn có chắc muốn thu hồi tin nhắn này?<br>Tin nhắn sẽ bị ẩn với tất cả mọi người.",
92524
- allowOutsideClick: false,
92525
- showCancelButton: true,
92526
- confirmButtonText: "Thu hồi",
92527
- cancelButtonText: "Hủy",
92528
- customClass: {
92529
- confirmButton: "btn btn-primary",
92530
- cancelButton: "btn btn-danger ms-1"
92531
- },
92532
- buttonsStyling: false
92533
- });
92534
- if (result.value) {
92535
- const data = { id: param.id, chatRoomId: groupChatUsers.id };
92536
- await recallMessageApi(data);
92537
- }
92538
- else if (result.dismiss === MySwal$1.DismissReason.cancel) {
92539
- console.log("Hủy thu hồi tin nhắn");
92540
- }
92541
- }
92542
- catch (error) {
92543
- console.error("Error recalling message:", error);
92544
- }
92545
- }, [recallMessageApi, groupChatUsers?.id]);
92546
- useCallback(async (val) => {
92547
- switch (val.id) {
92548
- case "copyImage":
92549
- try {
92550
- // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
92551
- const targetFile = clickedImageFile || val?.currentMessage?.path?.[0];
92552
- const imagePath = targetFile?.path;
92553
- if (!imagePath) {
92554
- console.error('Không tìm thấy đường dẫn ảnh');
92555
- return;
92556
- }
92557
- const imgUrl = `${CDN_URL_VIEW}/${imagePath}`;
92558
- const response = await fetch(imgUrl);
92559
- const blob = await response.blob();
92560
- await navigator.clipboard.write([
92561
- new ClipboardItem({
92562
- [blob.type]: blob
92563
- })
92564
- ]);
92565
- }
92566
- catch (error) {
92567
- console.error('Lỗi khi copy ảnh:', error);
92568
- }
92569
- break;
92570
- case "copyText":
92571
- navigator.clipboard.writeText(val?.currentMessage.msg);
92572
- break;
92573
- case "reply":
92574
- setReplyMessage(val);
92575
- break;
92576
- case "save":
92577
- handleDownloadClick(val.currentMessage);
92578
- break;
92579
- case "delete":
92580
- handleDelete(val.currentMessage);
92581
- break;
92582
- case "recall":
92583
- handleRecall(val.currentMessage);
92584
- break;
92585
- }
92586
- }, [clickedImageFile, handleDelete, handleDownloadClick, handleRecall]);
92481
+ // const handleDownloadClick = useCallback((param: any) => {
92482
+ // // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
92483
+ // const targetFile = clickedImageFile || param?.path?.[0]
92484
+ // if (targetFile?.path) {
92485
+ // downloadFile(targetFile.path)
92486
+ // } else {
92487
+ // console.error("No valid path found in param")
92488
+ // }
92489
+ // }, [clickedImageFile, downloadFile])
92490
+ // const handleDelete = useCallback(async (param: any) => {
92491
+ // try {
92492
+ // const result = await MySwal.fire({
92493
+ // title: "Xác nhận",
92494
+ // html: "Tin nhắn sẽ bị xóa vĩnh viễn. <br> Bạn có chắc muốn xóa?",
92495
+ // allowOutsideClick: false,
92496
+ // showCancelButton: true,
92497
+ // confirmButtonText: "Xoá",
92498
+ // cancelButtonText: "Hủy",
92499
+ // customClass: {
92500
+ // confirmButton: "btn btn-primary",
92501
+ // cancelButton: "btn btn-danger ms-1"
92502
+ // },
92503
+ // buttonsStyling: false
92504
+ // })
92505
+ // if (result.value) {
92506
+ // const data = { id: param.id, chatRoomId: groupChatUsers.id }
92507
+ // await deleteMessageApi(data)
92508
+ // } else if (result.dismiss === MySwal.DismissReason.cancel) {
92509
+ // console.log("Hủy xóa tin nhắn")
92510
+ // }
92511
+ // } catch (error) {
92512
+ // console.error("Error deleting message:", error)
92513
+ // }
92514
+ // }, [deleteMessageApi, groupChatUsers?.id])
92515
+ // const handleRecall = useCallback(async (param: any) => {
92516
+ // try {
92517
+ // const result = await MySwal.fire({
92518
+ // title: "Xác nhận",
92519
+ // html: "Bạn có chắc muốn thu hồi tin nhắn này?<br>Tin nhắn sẽ bị ẩn với tất cả mọi người.",
92520
+ // allowOutsideClick: false,
92521
+ // showCancelButton: true,
92522
+ // confirmButtonText: "Thu hồi",
92523
+ // cancelButtonText: "Hủy",
92524
+ // customClass: {
92525
+ // confirmButton: "btn btn-primary",
92526
+ // cancelButton: "btn btn-danger ms-1"
92527
+ // },
92528
+ // buttonsStyling: false
92529
+ // })
92530
+ // if (result.value) {
92531
+ // const data = { id: param.id, chatRoomId: groupChatUsers.id }
92532
+ // await recallMessageApi(data)
92533
+ // } else if (result.dismiss === MySwal.DismissReason.cancel) {
92534
+ // console.log("Hủy thu hồi tin nhắn")
92535
+ // }
92536
+ // } catch (error) {
92537
+ // console.error("Error recalling message:", error)
92538
+ // }
92539
+ // }, [recallMessageApi, groupChatUsers?.id])
92540
+ // const contextMenuClick = useCallback(async (val: any) => {
92541
+ // switch (val.id) {
92542
+ // case "copyImage":
92543
+ // try {
92544
+ // // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
92545
+ // const targetFile = clickedImageFile || val?.currentMessage?.path?.[0]
92546
+ // const imagePath = targetFile?.path
92547
+ // if (!imagePath) {
92548
+ // console.error('Không tìm thấy đường dẫn ảnh')
92549
+ // return
92550
+ // }
92551
+ // const imgUrl = `${CDN_URL_VIEW}/${imagePath}`
92552
+ // const response = await fetch(imgUrl)
92553
+ // const blob = await response.blob()
92554
+ // await navigator.clipboard.write([
92555
+ // new ClipboardItem({
92556
+ // [blob.type]: blob
92557
+ // })
92558
+ // ])
92559
+ // } catch (error) {
92560
+ // console.error('Lỗi khi copy ảnh:', error)
92561
+ // }
92562
+ // break
92563
+ // case "copyText":
92564
+ // navigator.clipboard.writeText(val?.currentMessage.msg)
92565
+ // break
92566
+ // case "reply":
92567
+ // setReplyMessage(val)
92568
+ // break
92569
+ // case "save":
92570
+ // handleDownloadClick(val.currentMessage)
92571
+ // break
92572
+ // case "delete":
92573
+ // handleDelete(val.currentMessage)
92574
+ // break
92575
+ // case "recall":
92576
+ // handleRecall(val.currentMessage)
92577
+ // break
92578
+ // default:
92579
+ // break
92580
+ // }
92581
+ // }, [clickedImageFile, handleDelete, handleDownloadClick, handleRecall])
92587
92582
  // const handleFocus = useCallback(() => {
92588
92583
  // editor.focus()
92589
92584
  // }, [editor])