feat: 解析Email气泡; 获取详情

2.0/email-builder
Lei OT 11 months ago
parent 1cc49126ee
commit 2d48792902

@ -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 || [] };
}

@ -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, }),
},
};
/**

@ -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)

@ -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",

@ -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;

@ -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 ? '' : (<WABASwitcher />), icon: <WABIcon />, children: <InputComposer channel={'waba'} /> },
{ key: 'waba', label: mobile ? '' : 'WA商业号-Global Highlights', icon: <WABIcon />, children: <InputComposer channel={'waba'} /> }, // todo:
{ key: 'email', label: mobile ? '' : 'Email', icon: <MailOutlined className='text-indigo-500' />, children: <EmailComposer /> },
// { key: 'whatsapp', label: mobile ? '' : 'WhatsApp', icon: <WhatsAppOutlined className='text-whatsapp' />, children: <InputComposer channel={'whatsapp'} /> },
{ key: 'whatsapp', label: mobile ? '' : 'WhatsApp', icon: <WhatsAppOutlined className='text-whatsapp' />, children: <div className='p-2 py-4 text-center text-whatsapp bg-gray-200 rounded rounded-b-none border-gray-300 border-solid border border-b-0 border-x-0'>敬请期待</div> },
{ key: 'wa', label: mobile ? '' : 'WhatsApp', icon: <WhatsAppOutlined className='text-whatsapp' />, children: <div className='p-2 py-4 text-center text-whatsapp bg-gray-200 rounded rounded-b-none border-gray-300 border-solid border border-b-0 border-x-0'>敬请期待</div> },
];
return (

Loading…
Cancel
Save