@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.js CHANGED
@@ -91777,7 +91777,6 @@ const IconFileTypeColor = (props) => {
91777
91777
  return jsxRuntime.jsx("img", { ...props, src: icon, style: { width: width ? width : 24, height: height ? height : 'auto', ...props.style } });
91778
91778
  };
91779
91779
 
91780
- const MySwal$1 = withReactContent(Swal);
91781
91780
  const DateHeader = React.memo(({ label }) => (jsxRuntime.jsx("div", { className: "d-flex justify-content-center", children: jsxRuntime.jsx("div", { style: {
91782
91781
  backgroundColor: "rgba(0,0,0,0.2)",
91783
91782
  padding: "2px 15px",
@@ -92511,7 +92510,7 @@ const ChatLog = (props) => {
92511
92510
  backgroundImage: `url(${`${CDN_URL_VIEW}/${replyData?.path[0].path.trim()}`})`
92512
92511
  } })), replyData?.type === "file" && (jsxRuntime.jsx("div", { style: { marginRight: 8 }, children: jsxRuntime.jsx(IconFileTypeColor, { fileType: replyData?.path?.[0]?.type, width: 35 }) })), jsxRuntime.jsxs("div", { className: "reply-content d-flex flex-column", children: [jsxRuntime.jsx("div", { className: "fw-bold", children: replyData?.createdByName }), jsxRuntime.jsx("div", { children: renderMessageReply(replyData?.type, replyData?.msg) })] })] }) }));
92513
92512
  }, [renderMessageReply]);
92514
- const downloadFile = React.useCallback(async (path) => {
92513
+ React.useCallback(async (path) => {
92515
92514
  const url = `${CDN_URL_VIEW}/${path}`;
92516
92515
  try {
92517
92516
  const response = await axios$1.get(url, { responseType: "blob" });
@@ -92528,111 +92527,107 @@ const ChatLog = (props) => {
92528
92527
  console.error(error);
92529
92528
  }
92530
92529
  }, []);
92531
- const handleDownloadClick = React.useCallback((param) => {
92532
- // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
92533
- const targetFile = clickedImageFile || param?.path?.[0];
92534
- if (targetFile?.path) {
92535
- downloadFile(targetFile.path);
92536
- }
92537
- else {
92538
- console.error("No valid path found in param");
92539
- }
92540
- }, [clickedImageFile, downloadFile]);
92541
- const handleDelete = React.useCallback(async (param) => {
92542
- try {
92543
- const result = await MySwal$1.fire({
92544
- title: "Xác nhận",
92545
- html: "Tin nhắn sẽ bị xóa vĩnh viễn. <br> Bạn có chắc muốn xóa?",
92546
- allowOutsideClick: false,
92547
- showCancelButton: true,
92548
- confirmButtonText: "Xoá",
92549
- cancelButtonText: "Hủy",
92550
- customClass: {
92551
- confirmButton: "btn btn-primary",
92552
- cancelButton: "btn btn-danger ms-1"
92553
- },
92554
- buttonsStyling: false
92555
- });
92556
- if (result.value) {
92557
- const data = { id: param.id, chatRoomId: groupChatUsers.id };
92558
- await deleteMessageApi(data);
92559
- }
92560
- else if (result.dismiss === MySwal$1.DismissReason.cancel) {
92561
- console.log("Hủy xóa tin nhắn");
92562
- }
92563
- }
92564
- catch (error) {
92565
- console.error("Error deleting message:", error);
92566
- }
92567
- }, [deleteMessageApi, groupChatUsers?.id]);
92568
- const handleRecall = React.useCallback(async (param) => {
92569
- try {
92570
- const result = await MySwal$1.fire({
92571
- title: "Xác nhận",
92572
- 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.",
92573
- allowOutsideClick: false,
92574
- showCancelButton: true,
92575
- confirmButtonText: "Thu hồi",
92576
- cancelButtonText: "Hủy",
92577
- customClass: {
92578
- confirmButton: "btn btn-primary",
92579
- cancelButton: "btn btn-danger ms-1"
92580
- },
92581
- buttonsStyling: false
92582
- });
92583
- if (result.value) {
92584
- const data = { id: param.id, chatRoomId: groupChatUsers.id };
92585
- await recallMessageApi(data);
92586
- }
92587
- else if (result.dismiss === MySwal$1.DismissReason.cancel) {
92588
- console.log("Hủy thu hồi tin nhắn");
92589
- }
92590
- }
92591
- catch (error) {
92592
- console.error("Error recalling message:", error);
92593
- }
92594
- }, [recallMessageApi, groupChatUsers?.id]);
92595
- React.useCallback(async (val) => {
92596
- switch (val.id) {
92597
- case "copyImage":
92598
- try {
92599
- // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
92600
- const targetFile = clickedImageFile || val?.currentMessage?.path?.[0];
92601
- const imagePath = targetFile?.path;
92602
- if (!imagePath) {
92603
- console.error('Không tìm thấy đường dẫn ảnh');
92604
- return;
92605
- }
92606
- const imgUrl = `${CDN_URL_VIEW}/${imagePath}`;
92607
- const response = await fetch(imgUrl);
92608
- const blob = await response.blob();
92609
- await navigator.clipboard.write([
92610
- new ClipboardItem({
92611
- [blob.type]: blob
92612
- })
92613
- ]);
92614
- }
92615
- catch (error) {
92616
- console.error('Lỗi khi copy ảnh:', error);
92617
- }
92618
- break;
92619
- case "copyText":
92620
- navigator.clipboard.writeText(val?.currentMessage.msg);
92621
- break;
92622
- case "reply":
92623
- setReplyMessage(val);
92624
- break;
92625
- case "save":
92626
- handleDownloadClick(val.currentMessage);
92627
- break;
92628
- case "delete":
92629
- handleDelete(val.currentMessage);
92630
- break;
92631
- case "recall":
92632
- handleRecall(val.currentMessage);
92633
- break;
92634
- }
92635
- }, [clickedImageFile, handleDelete, handleDownloadClick, handleRecall]);
92530
+ // const handleDownloadClick = useCallback((param: any) => {
92531
+ // // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
92532
+ // const targetFile = clickedImageFile || param?.path?.[0]
92533
+ // if (targetFile?.path) {
92534
+ // downloadFile(targetFile.path)
92535
+ // } else {
92536
+ // console.error("No valid path found in param")
92537
+ // }
92538
+ // }, [clickedImageFile, downloadFile])
92539
+ // const handleDelete = useCallback(async (param: any) => {
92540
+ // try {
92541
+ // const result = await MySwal.fire({
92542
+ // title: "Xác nhận",
92543
+ // html: "Tin nhắn sẽ bị xóa vĩnh viễn. <br> Bạn có chắc muốn xóa?",
92544
+ // allowOutsideClick: false,
92545
+ // showCancelButton: true,
92546
+ // confirmButtonText: "Xoá",
92547
+ // cancelButtonText: "Hủy",
92548
+ // customClass: {
92549
+ // confirmButton: "btn btn-primary",
92550
+ // cancelButton: "btn btn-danger ms-1"
92551
+ // },
92552
+ // buttonsStyling: false
92553
+ // })
92554
+ // if (result.value) {
92555
+ // const data = { id: param.id, chatRoomId: groupChatUsers.id }
92556
+ // await deleteMessageApi(data)
92557
+ // } else if (result.dismiss === MySwal.DismissReason.cancel) {
92558
+ // console.log("Hủy xóa tin nhắn")
92559
+ // }
92560
+ // } catch (error) {
92561
+ // console.error("Error deleting message:", error)
92562
+ // }
92563
+ // }, [deleteMessageApi, groupChatUsers?.id])
92564
+ // const handleRecall = useCallback(async (param: any) => {
92565
+ // try {
92566
+ // const result = await MySwal.fire({
92567
+ // title: "Xác nhận",
92568
+ // 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.",
92569
+ // allowOutsideClick: false,
92570
+ // showCancelButton: true,
92571
+ // confirmButtonText: "Thu hồi",
92572
+ // cancelButtonText: "Hủy",
92573
+ // customClass: {
92574
+ // confirmButton: "btn btn-primary",
92575
+ // cancelButton: "btn btn-danger ms-1"
92576
+ // },
92577
+ // buttonsStyling: false
92578
+ // })
92579
+ // if (result.value) {
92580
+ // const data = { id: param.id, chatRoomId: groupChatUsers.id }
92581
+ // await recallMessageApi(data)
92582
+ // } else if (result.dismiss === MySwal.DismissReason.cancel) {
92583
+ // console.log("Hủy thu hồi tin nhắn")
92584
+ // }
92585
+ // } catch (error) {
92586
+ // console.error("Error recalling message:", error)
92587
+ // }
92588
+ // }, [recallMessageApi, groupChatUsers?.id])
92589
+ // const contextMenuClick = useCallback(async (val: any) => {
92590
+ // switch (val.id) {
92591
+ // case "copyImage":
92592
+ // try {
92593
+ // // Ưu tiên ảnh được click, fallback về ảnh đầu tiên
92594
+ // const targetFile = clickedImageFile || val?.currentMessage?.path?.[0]
92595
+ // const imagePath = targetFile?.path
92596
+ // if (!imagePath) {
92597
+ // console.error('Không tìm thấy đường dẫn ảnh')
92598
+ // return
92599
+ // }
92600
+ // const imgUrl = `${CDN_URL_VIEW}/${imagePath}`
92601
+ // const response = await fetch(imgUrl)
92602
+ // const blob = await response.blob()
92603
+ // await navigator.clipboard.write([
92604
+ // new ClipboardItem({
92605
+ // [blob.type]: blob
92606
+ // })
92607
+ // ])
92608
+ // } catch (error) {
92609
+ // console.error('Lỗi khi copy ảnh:', error)
92610
+ // }
92611
+ // break
92612
+ // case "copyText":
92613
+ // navigator.clipboard.writeText(val?.currentMessage.msg)
92614
+ // break
92615
+ // case "reply":
92616
+ // setReplyMessage(val)
92617
+ // break
92618
+ // case "save":
92619
+ // handleDownloadClick(val.currentMessage)
92620
+ // break
92621
+ // case "delete":
92622
+ // handleDelete(val.currentMessage)
92623
+ // break
92624
+ // case "recall":
92625
+ // handleRecall(val.currentMessage)
92626
+ // break
92627
+ // default:
92628
+ // break
92629
+ // }
92630
+ // }, [clickedImageFile, handleDelete, handleDownloadClick, handleRecall])
92636
92631
  // const handleFocus = useCallback(() => {
92637
92632
  // editor.focus()
92638
92633
  // }, [editor])