diff --git a/src/actions/EmailActions.js b/src/actions/EmailActions.js
index 5e511db..5cb97d9 100644
--- a/src/actions/EmailActions.js
+++ b/src/actions/EmailActions.js
@@ -35,8 +35,6 @@ export const postSendEmail = async (body) => {
* @param {object} { mai_sn }
*/
export const getEmailDetailAction = async (param) => {
- const { result } = await fetchJSON(
- `${EMAIL_HOST}/getmail?mai_sn=5036841`, // param
- );
+ const { result } = await fetchJSON(`${EMAIL_HOST}/getmail`, param);
return { info: result.MailInfo?.[0] || {}, content: result.MailContent || '', attachments: result?.AttachList || [] };
}
diff --git a/src/channel/bubbleMsgUtils.js b/src/channel/bubbleMsgUtils.js
index 4db870b..5ae5f21 100644
--- a/src/channel/bubbleMsgUtils.js
+++ b/src/channel/bubbleMsgUtils.js
@@ -516,7 +516,8 @@ export const whatsappMsgTypeMapped = {
},
},
email: {
- data: (msg) => ({ id: msg.id, subject: msg.email.subject, title: msg?.customerProfile?.name || '' }),
+ type: 'email',
+ data: (msg) => ({ id: msg.id, subject: msg.email.subject, }),
},
};
/**
diff --git a/src/views/Conversations/Online/Components/EmailDetail.jsx b/src/views/Conversations/Online/Components/EmailDetail.jsx
index eba10d3..b8cdee4 100644
--- a/src/views/Conversations/Online/Components/EmailDetail.jsx
+++ b/src/views/Conversations/Online/Components/EmailDetail.jsx
@@ -19,7 +19,8 @@ const TagColorStyle = (tag) => {
const EmailDetail = ({ open, setOpen, emailMsg, ...props }) => {
// console.log('emailMsg', emailMsg);
- let { conversationid, msg_id } = emailMsg
+ let { conversationid, } = emailMsg
+ const { mai_sn } = emailMsg.msgtext?.email || {}
// const [open, setOpen] = useState(false);
const [initialPosition, setInitialPosition] = useState({})
const [initialSize, setInitialSize] = useState({})
@@ -51,7 +52,7 @@ const EmailDetail = ({ open, setOpen, emailMsg, ...props }) => {
const [mailData, setMailData] = useState({info: {}, content: '', attachments: []})
const getEmailDetail = async () => {
- const data = await getEmailDetailAction({ mai_sn: msg_id })
+ const data = await getEmailDetailAction({ mai_sn })
console.log('data', data);
setMailData(data)
diff --git a/src/views/Conversations/Online/Components/emailSent.json b/src/views/Conversations/Online/Components/emailSent.json
index 88f3cc5..e01e129 100644
--- a/src/views/Conversations/Online/Components/emailSent.json
+++ b/src/views/Conversations/Online/Components/emailSent.json
@@ -1,38 +1,45 @@
{
"conversationid": 2983,
"sn": 14201,
- "msg_direction": "outbound",
+ "msg_direction": "inbound",
"msgtime": "2024-02-21T11:37:33",
- "msgtext_AsJOSN": {},
"msgtype": "email",
- "template_AsJOSN": {},
- "messageorigin_AsJOSN": [],
- "messageorigin_direction": "outbound",
+ "template": {},
+ "messageorigin": [],
+ "messageorigin_direction": "inbound",
"orgmsgtime": "2024-02-22T00:41:30",
"msgOrigin": {},
- "id": "emailid.qjMVpfPuxd8cwKs9o3bGIgYL6SWinB5vHRyQX1ZTU4OmeEAtDk07zaF=",
"text": "",
"title": "",
"type": "email",
- "emailOrigin": {
- "id": "emailid.qjMVpfPuxd8cwKs9o3bGIgYL6SWinB5vHRyQX1ZTU4OmeEAtDk07zaF=",
- "status": "read",
- "fromName": "LYT-HN",
- "fromEmail": "lyt@hainatravel.com",
- "toName": "LYT",
- "toEmail": "ldj_yt@outlook.com",
- "cc": "lioyjun@gmail.com",
- "bcc": "",
- "subject": "发送示例",
- "content": "发送示例发送示例发送示例发送示例",
- "abstract": "发送示例发送示例发送示例发送示例发送示例……",
- "replyToEmail": "lyt@hainatravel.com",
- "replyToName": "LYT-HN",
- "senderEmail": "",
- "senderName": "",
- "bCopyEmail1": "",
- "priority": "",
- "sent": "2024-02-21T03:37:33.000Z",
+ "msg_source": "email",
+ "msgtext": {
+ "id": "932c881ea7a747a9a61c",
+ "to": "charles@hainatravel.com",
+ "from": "xxx@aol.com",
+ "type": "email",
+ "email": {
+ "mai_sn": 123,
+ "content": "this is content",
+ "subject": "this is a title"
+ },
+ "wamid": null,
+ "status": "send",
+ "wabaId": null,
+ "readTime": null,
+ "sendTime": "2024-10-23 16:24:23.000000",
+ "createTime": "2024-10-28 14:32:13.499",
+ "externalId": null,
+ "regionCode": null,
+ "updateTime": null,
+ "deliverTime": null,
+ "conversation": {
+ "id": null,
+ "type": null,
+ "expireTime": null,
+ "originType": null
+ },
+ "link_original": null,
"#": "#"
},
"date": "2024-02-21T03:37:33.000Z",
diff --git a/src/views/Conversations/Online/MessagesWrapper.jsx b/src/views/Conversations/Online/MessagesWrapper.jsx
index 49b18cd..387666c 100644
--- a/src/views/Conversations/Online/MessagesWrapper.jsx
+++ b/src/views/Conversations/Online/MessagesWrapper.jsx
@@ -40,7 +40,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
useEffect(() => {
setLongList(activeMessages);
- const thisLastTime = activeMessages.length > 0 ? activeMessages[0].orgmsgtime : '';
+ const thisLastTime = activeMessages.length > 0 ? activeMessages[0].msgtime : '';
const loadNextPage = !(activeMessages.length === 0 || activeMessages.length < MESSAGE_PAGE_SIZE);
updateCurrentConversation({ lasttime: thisLastTime, loadNextPage });
return () => {};
@@ -64,6 +64,9 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
whatsappid: item.whatsapp_phone_number,
lasttime: '',
})
+ const thisLastTime = data.length > 0 ? data[0].msgtime : ''; // orgmsgtime
+ const loadNextPage = !(data.length === 0 || data.length < MESSAGE_PAGE_SIZE);
+ updateCurrentConversation({ lasttime: thisLastTime, loadNextPage });
// test:
data.push(emailItem);
@@ -71,9 +74,6 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
setMsgLoading(false);
receivedMessageList(item.sn, data);
- const thisLastTime = data.length > 0 ? data[0].orgmsgtime : '';
- const loadNextPage = !(data.length === 0 || data.length < MESSAGE_PAGE_SIZE);
- updateCurrentConversation({ lasttime: thisLastTime, loadNextPage });
};
const getMoreMessages = async () => {
@@ -87,7 +87,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
})
setLongListLoading(false);
setLongList(prevValue => data.concat(prevValue));
- const thisLastTime = data.length > 0 ? data[0].orgmsgtime : '';
+ const thisLastTime = data.length > 0 ? data[0].msgtime : '';
const loadNextPage = !(data.length === 0 || data.length < MESSAGE_PAGE_SIZE);
updateCurrentConversation({ lasttime: thisLastTime, loadNextPage });
return data.length;
diff --git a/src/views/Conversations/Online/ReplyWrapper.jsx b/src/views/Conversations/Online/ReplyWrapper.jsx
index a1d98da..d88e1fc 100644
--- a/src/views/Conversations/Online/ReplyWrapper.jsx
+++ b/src/views/Conversations/Online/ReplyWrapper.jsx
@@ -7,6 +7,7 @@ import { WABIcon } from '@/components/Icons';
import useConversationStore from '@/stores/ConversationStore';
import { useShallow } from 'zustand/react/shallow';
import useStyleStore from '@/stores/StyleStore';
+import { isEmpty } from '@/utils/commons';
const DEFAULT_CHANNEL = 'waba';
const Wabas = [
@@ -45,6 +46,7 @@ const ReplyWrapper = () => {
setActiveChannel(activeKey);
};
+ const [referenceMsg] = useConversationStore((state) => [state.referenceMsg]);
const activeMessages = useConversationStore(
useShallow((state) => (state.currentConversation.sn && state.activeConversations[state.currentConversation.sn] ? state.activeConversations[state.currentConversation.sn] : []))
);
@@ -56,12 +58,20 @@ const ReplyWrapper = () => {
return () => {};
}, [activeMessages]);
+ useEffect(() => {
+ if (!isEmpty(referenceMsg.msg_source)) {
+ setActiveChannel((referenceMsg.msg_source).toLowerCase())
+ }
+ return () => {}
+ }, [referenceMsg.msg_source])
+
+
const replyTypes = [
// { key: 'waba', label: mobile ? '' : (