@esvndev/es-react-template-chat 0.0.102 → 0.0.103

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
@@ -72493,6 +72493,18 @@ const ChatLog = (props) => {
72493
72493
  }
72494
72494
  }
72495
72495
  }, []);
72496
+ const useParsedChatData = (chatMsg) => {
72497
+ if (!chatMsg) {
72498
+ return {};
72499
+ }
72500
+ try {
72501
+ return typeof chatMsg === 'string' ? JSON.parse(chatMsg) : chatMsg;
72502
+ }
72503
+ catch (err) {
72504
+ console.error('JSON parse error:', err);
72505
+ return {};
72506
+ }
72507
+ };
72496
72508
  useCallback((chat) => {
72497
72509
  const isPath = Array.isArray(chat?.path) && typeof chat.path[0]?.path === "string" ? chat.path[0].path.trim() : "";
72498
72510
  const img = isPath ? `${CDN_URL_VIEW}/${isPath}` : "";
@@ -72904,7 +72916,7 @@ const ChatLog = (props) => {
72904
72916
  setOpenModalReminder(true);
72905
72917
  }, children: "Xem chi ti\u1EBFt" })] }));
72906
72918
  }, []);
72907
- useCallback((type, msg, path) => {
72919
+ const renderMessageReply = useCallback((type, msg, path) => {
72908
72920
  switch (type) {
72909
72921
  case "file": // ✅ THÊM CASE NÀY
72910
72922
  const fileName = path?.[0]?.name || '';
@@ -72915,41 +72927,14 @@ const ChatLog = (props) => {
72915
72927
  return msg;
72916
72928
  }
72917
72929
  }, []);
72918
- // const renderReplyContent = useCallback((replyMsg: any) => {
72919
- // const replyData = useParsedChatData(replyMsg)
72920
- // return (
72921
- // <div
72922
- // className={classnames("chat-app-reply p-0 mb-50", {
72923
- // show: true
72924
- // })}
72925
- // >
72926
- // <div className="reply-container">
72927
- // <div className="reply-quote" />
72928
- // {replyData?.type === "image" && (
72929
- // <div
72930
- // className="reply-image"
72931
- // style={{
72932
- // backgroundImage: `url(${`${CDN_URL_VIEW}/${replyData?.path[0].path.trim()}`})`
72933
- // }}
72934
- // />
72935
- // )}
72936
- // {/* ✅ THÊM: File */}
72937
- // {replyData?.type === "file" && (
72938
- // <div style={{ marginRight: 8 }}>
72939
- // <IconFileTypeColor
72940
- // fileType={replyData?.path?.[0]?.type}
72941
- // width={35}
72942
- // />
72943
- // </div>
72944
- // )}
72945
- // <div className="reply-content d-flex flex-column">
72946
- // <div className="fw-bold">{replyData?.createdByName}</div>
72947
- // <div>{renderMessageReply(replyData?.type, replyData?.msg)}</div>
72948
- // </div>
72949
- // </div>
72950
- // </div>
72951
- // )
72952
- // }, [renderMessageReply])
72930
+ useCallback((replyMsg) => {
72931
+ const replyData = useParsedChatData(replyMsg);
72932
+ return (jsx("div", { className: classnames("chat-app-reply p-0 mb-50", {
72933
+ show: true
72934
+ }), children: jsxs("div", { className: "reply-container", children: [jsx("div", { className: "reply-quote" }), replyData?.type === "image" && (jsx("div", { className: "reply-image", style: {
72935
+ backgroundImage: `url(${`${CDN_URL_VIEW}/${replyData?.path[0].path.trim()}`})`
72936
+ } })), 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) })] })] }) }));
72937
+ }, [renderMessageReply]);
72953
72938
  // const downloadFile = useCallback(async (path: string) => {
72954
72939
  // const url = `${CDN_URL_VIEW}/${path}`
72955
72940
  // try {