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

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

@ -35,8 +35,6 @@ export const postSendEmail = async (body) => {
* @param {object} { mai_sn } * @param {object} { mai_sn }
*/ */
export const getEmailDetailAction = async (param) => { export const getEmailDetailAction = async (param) => {
const { result } = await fetchJSON( const { result } = await fetchJSON(`${EMAIL_HOST}/getmail`, param);
`${EMAIL_HOST}/getmail?mai_sn=5036841`, // param
);
return { info: result.MailInfo?.[0] || {}, content: result.MailContent || '', attachments: result?.AttachList || [] }; return { info: result.MailInfo?.[0] || {}, content: result.MailContent || '', attachments: result?.AttachList || [] };
} }

@ -516,7 +516,8 @@ export const whatsappMsgTypeMapped = {
}, },
}, },
email: { 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 }) => { const EmailDetail = ({ open, setOpen, emailMsg, ...props }) => {
// console.log('emailMsg', emailMsg); // console.log('emailMsg', emailMsg);
let { conversationid, msg_id } = emailMsg let { conversationid, } = emailMsg
const { mai_sn } = emailMsg.msgtext?.email || {}
// const [open, setOpen] = useState(false); // const [open, setOpen] = useState(false);
const [initialPosition, setInitialPosition] = useState({}) const [initialPosition, setInitialPosition] = useState({})
const [initialSize, setInitialSize] = useState({}) const [initialSize, setInitialSize] = useState({})
@ -51,7 +52,7 @@ const EmailDetail = ({ open, setOpen, emailMsg, ...props }) => {
const [mailData, setMailData] = useState({info: {}, content: '', attachments: []}) const [mailData, setMailData] = useState({info: {}, content: '', attachments: []})
const getEmailDetail = async () => { const getEmailDetail = async () => {
const data = await getEmailDetailAction({ mai_sn: msg_id }) const data = await getEmailDetailAction({ mai_sn })
console.log('data', data); console.log('data', data);
setMailData(data) setMailData(data)

@ -1,38 +1,45 @@
{ {
"conversationid": 2983, "conversationid": 2983,
"sn": 14201, "sn": 14201,
"msg_direction": "outbound", "msg_direction": "inbound",
"msgtime": "2024-02-21T11:37:33", "msgtime": "2024-02-21T11:37:33",
"msgtext_AsJOSN": {},
"msgtype": "email", "msgtype": "email",
"template_AsJOSN": {}, "template": {},
"messageorigin_AsJOSN": [], "messageorigin": [],
"messageorigin_direction": "outbound", "messageorigin_direction": "inbound",
"orgmsgtime": "2024-02-22T00:41:30", "orgmsgtime": "2024-02-22T00:41:30",
"msgOrigin": {}, "msgOrigin": {},
"id": "emailid.qjMVpfPuxd8cwKs9o3bGIgYL6SWinB5vHRyQX1ZTU4OmeEAtDk07zaF=",
"text": "", "text": "",
"title": "", "title": "",
"type": "email", "type": "email",
"emailOrigin": { "msg_source": "email",
"id": "emailid.qjMVpfPuxd8cwKs9o3bGIgYL6SWinB5vHRyQX1ZTU4OmeEAtDk07zaF=", "msgtext": {
"status": "read", "id": "932c881ea7a747a9a61c",
"fromName": "LYT-HN", "to": "charles@hainatravel.com",
"fromEmail": "lyt@hainatravel.com", "from": "xxx@aol.com",
"toName": "LYT", "type": "email",
"toEmail": "ldj_yt@outlook.com", "email": {
"cc": "lioyjun@gmail.com", "mai_sn": 123,
"bcc": "", "content": "this is content",
"subject": "发送示例", "subject": "this is a title"
"content": "发送示例发送示例发送示例发送示例", },
"abstract": "发送示例发送示例发送示例发送示例发送示例……", "wamid": null,
"replyToEmail": "lyt@hainatravel.com", "status": "send",
"replyToName": "LYT-HN", "wabaId": null,
"senderEmail": "", "readTime": null,
"senderName": "", "sendTime": "2024-10-23 16:24:23.000000",
"bCopyEmail1": "", "createTime": "2024-10-28 14:32:13.499",
"priority": "", "externalId": null,
"sent": "2024-02-21T03:37:33.000Z", "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", "date": "2024-02-21T03:37:33.000Z",

@ -40,7 +40,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
useEffect(() => { useEffect(() => {
setLongList(activeMessages); 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); const loadNextPage = !(activeMessages.length === 0 || activeMessages.length < MESSAGE_PAGE_SIZE);
updateCurrentConversation({ lasttime: thisLastTime, loadNextPage }); updateCurrentConversation({ lasttime: thisLastTime, loadNextPage });
return () => {}; return () => {};
@ -64,6 +64,9 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
whatsappid: item.whatsapp_phone_number, whatsappid: item.whatsapp_phone_number,
lasttime: '', 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: // test:
data.push(emailItem); data.push(emailItem);
@ -71,9 +74,6 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
setMsgLoading(false); setMsgLoading(false);
receivedMessageList(item.sn, data); 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 () => { const getMoreMessages = async () => {
@ -87,7 +87,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
}) })
setLongListLoading(false); setLongListLoading(false);
setLongList(prevValue => data.concat(prevValue)); 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); const loadNextPage = !(data.length === 0 || data.length < MESSAGE_PAGE_SIZE);
updateCurrentConversation({ lasttime: thisLastTime, loadNextPage }); updateCurrentConversation({ lasttime: thisLastTime, loadNextPage });
return data.length; return data.length;

@ -7,6 +7,7 @@ import { WABIcon } from '@/components/Icons';
import useConversationStore from '@/stores/ConversationStore'; import useConversationStore from '@/stores/ConversationStore';
import { useShallow } from 'zustand/react/shallow'; import { useShallow } from 'zustand/react/shallow';
import useStyleStore from '@/stores/StyleStore'; import useStyleStore from '@/stores/StyleStore';
import { isEmpty } from '@/utils/commons';
const DEFAULT_CHANNEL = 'waba'; const DEFAULT_CHANNEL = 'waba';
const Wabas = [ const Wabas = [
@ -45,6 +46,7 @@ const ReplyWrapper = () => {
setActiveChannel(activeKey); setActiveChannel(activeKey);
}; };
const [referenceMsg] = useConversationStore((state) => [state.referenceMsg]);
const activeMessages = useConversationStore( const activeMessages = useConversationStore(
useShallow((state) => (state.currentConversation.sn && state.activeConversations[state.currentConversation.sn] ? state.activeConversations[state.currentConversation.sn] : [])) useShallow((state) => (state.currentConversation.sn && state.activeConversations[state.currentConversation.sn] ? state.activeConversations[state.currentConversation.sn] : []))
); );
@ -56,12 +58,20 @@ const ReplyWrapper = () => {
return () => {}; return () => {};
}, [activeMessages]); }, [activeMessages]);
useEffect(() => {
if (!isEmpty(referenceMsg.msg_source)) {
setActiveChannel((referenceMsg.msg_source).toLowerCase())
}
return () => {}
}, [referenceMsg.msg_source])
const replyTypes = [ const replyTypes = [
// { key: 'waba', label: mobile ? '' : (<WABASwitcher />), icon: <WABIcon />, children: <InputComposer channel={'waba'} /> }, // { 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: '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: '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: <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 ( return (

Loading…
Cancel
Save