Merge branch 'main' of github.com:hainatravel/global-sales

dev/emitter
Jimmy Liow 10 months ago
commit 64c5c4a1d5

@ -76,12 +76,13 @@ export const fetchOrderConversationsList = async (params) => {
export const MESSAGE_PAGE_SIZE = 50;
/**
*
* @param {object} params { opisn, whatsappid, conversationid, lasttime, pagesize }
* @param {object} params { coli_sn, opisn, whatsappid, conversationid, lasttime, pagesize }
*/
export const fetchMessages = async (params) => {
const defaultParams = {
// opisn: '',
// whatsappid: '',
coli_sn: '',
conversationid: '',
lasttime: '',
pagesize: MESSAGE_PAGE_SIZE,

@ -192,7 +192,7 @@ const EmailComposer = ({ ...props }) => {
<Input
className='rounded-b-none border-b-0 font-bold text-base text-indigo-600'
placeholder='*主题'
disabled={!talkabled}
disabled={!talkabled} allowClear
onFocus={() => handleFocus('subject')}
suffix={
<Tooltip title={'全文编辑'}>

@ -296,6 +296,45 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, fromOrder, toEma
newFileList.splice(index, 1);
setFileList(newFileList);
},
onPreview: (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = (e) => {
var dataURL = e.target.result;
var win = window.open("", "_blank");
win.document.body.style.margin = '0';
if (file.type.startsWith('image/')) {
win.document.write("<img src='" + e.target.result + "' />");
} else if (file.type.startsWith('text/') || file.type === 'application/html' || file.type === 'application/xhtml+xml') {
var iframe = win.document.createElement('iframe');
iframe.srcdoc = e.target.result;
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.border = 'none';
win.document.body.appendChild(iframe);
win.document.body.style.margin = '0';
} else if (file.type === 'application/pdf') {
win.document.write("<iframe src='" + e.target.result + "' width='100%' height='100%' style=\"border:none\"></iframe>");
win.document.body.style.margin = '0';
} else if (file.type.startsWith('audio/')) {
win.document.write("<audio controls src='" + e.target.result + "'></audio>");
} else if (file.type.startsWith('video/')) {
win.document.write("<video controls src='" + e.target.result + "'></video>");
} else {
win.document.write("<h2>Preview not available for this file type</h2>");
}
// win.document.write("<iframe src='" + dataURL + "' width='100%' height='100%' style=\"border:none\"></iframe>");
resolve(reader.result)
};
if (file.type.startsWith('text/') || file.type === 'application/html' || file.type === 'application/xhtml+xml') {
reader.readAsText(file);
} else {
reader.readAsDataURL(file);
}
// reader.readAsDataURL(file);
reader.onerror = (error) => reject(error);
})
},
};
/**

@ -1,26 +1,17 @@
import React, { useState, useRef, useEffect } from 'react';
import { App, Input, Flex, Button, Image, Tooltip } from 'antd';
import { App, Input, Flex, Button, Image } from 'antd';
import PropTypes from 'prop-types';
// import { Input } from 'react-chat-elements';
import useAuthStore from '@/stores/AuthStore';
import useConversationStore from '@/stores/ConversationStore';
import {
SendOutlined,
CloseCircleOutlined,
LoadingOutlined, FileOutlined,
DollarOutlined
} from '@ant-design/icons';
import { SendOutlined, CloseCircleOutlined, LoadingOutlined, FileOutlined } from '@ant-design/icons'
import { isEmpty, } from '@/utils/commons';
import { v4 as uuid } from 'uuid';
import { sentMsgTypeMapped, whatsappSupportFileTypes, uploadProgressSimulate } from '@/channel/bubbleMsgUtils';
import InputTemplate from './Template';
import InputEmoji from './Emoji';
import InputMediaUpload from './MediaUpload';
import { OSS_URL as aliOSSHost } from '@/config';
import { postUploadFileItem } from '@/actions/CommonActions';
import dayjs from 'dayjs';
import useStyleStore from '@/stores/StyleStore';
import { useOrderStore } from '@/stores/OrderStore'
import ComposerTools from './ComposerTools';
const ButtonStyleClsMapped =
@ -34,7 +25,6 @@ const InputComposer = ({ channel, currentActive }) => {
const [mobile] = useStyleStore((state) => [state.mobile]);
const {userId, whatsAppBusiness} = useAuthStore((state) => state.loginUser);
const [openPaymentDrawer] = useOrderStore((state) => [state.openDrawer])
const websocket = useConversationStore((state) => state.websocket);
const websocketOpened = useConversationStore((state) => state.websocketOpened);

@ -13,6 +13,7 @@ import emailReItem from './Components/emailRe.json';
import EmailEditorPopup from './Input/EmailEditorPopup';
import EmailDetail from './Components/EmailDetail';
import { useOrderStore, } from "@/stores/OrderStore";
import { isEmpty } from '@/utils/commons';
const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
const userId = useAuthStore((state) => state.loginUser.userId);
@ -27,7 +28,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
const refreshTotalNotify = useConversationStore(useShallow((state) => state.refreshTotalNotify));
const { orderDetail, } = useOrderStore();
const [orderDetail] = useOrderStore(state => [state.orderDetail]);
const isVisible = useVisibilityState();
@ -41,7 +42,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
}
setShouldScrollBottom(true);
return () => {};
}, [currentConversation.sn]);
}, [currentConversation.sn, orderDetail.coli_sn]);
useEffect(() => {
setLongList(activeMessages);
@ -68,6 +69,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
opisn: forceGetMessages ? currentConversation.opi_sn || '' : userId,
whatsappid: item.whatsapp_phone_number,
lasttime: '',
coli_sn: isEmpty(currentConversation.coli_sn) ? '' : (orderDetail.coli_sn || ''), // todo:
})
const thisLastTime = data.length > 0 ? data[0].msgtime : ''; // orgmsgtime
const loadNextPage = !(data.length === 0 || data.length < MESSAGE_PAGE_SIZE);
@ -85,6 +87,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
opisn: currentConversation.opi_sn,
whatsappid: currentConversation.whatsapp_phone_number,
lasttime: currentConversation?.lasttime || '',
coli_sn: isEmpty(currentConversation.coli_sn) ? '' : (orderDetail.coli_sn || ''),
})
setLongListLoading(false);
setLongList(prevValue => data.concat(prevValue));

@ -10,6 +10,7 @@ import useStyleStore from '@/stores/StyleStore';
import { isEmpty } from '@/utils/commons';
import { DEFAULT_CHANNEL } from '@/config';
import { WABAccounts, WABAccountsMapped } from '@/channel/bubbleMsgUtils';
import useAuthStore from '@/stores/AuthStore';
/**
* @ignore
@ -40,6 +41,7 @@ const WABASwitcher = ({ onSelect, }) => {
const ReplyWrapper = () => {
const [mobile] = useStyleStore(state => [state.mobile]);
const {userId, whatsAppBusiness} = useAuthStore((state) => state.loginUser);
const [activeChannel, setActiveChannel] = useState(DEFAULT_CHANNEL);
const onChannelTabsChange = (activeKey) => {
@ -52,9 +54,12 @@ const ReplyWrapper = () => {
);
useEffect(() => {
const len = activeMessages.length;
const thisLastChannel = activeMessages.length > 0 ? activeMessages[len - 1]?.type : DEFAULT_CHANNEL;
const thisLastChannel = activeMessages.length > 0 ? activeMessages[len - 1]?.msg_source : DEFAULT_CHANNEL;
const channel = thisLastChannel === 'email' ? 'email' : DEFAULT_CHANNEL;
setActiveChannel(channel);
setActiveChannel(thisLastChannel.toLowerCase());
return () => {};
}, [activeMessages]);
@ -68,7 +73,7 @@ const ReplyWrapper = () => {
const replyTypes = [
// { key: 'waba', label: mobile ? '' : (<WABASwitcher />), icon: <WABIcon />, children: <InputComposer channel={'waba'} /> },
{ key: 'waba', label: mobile ? '' : '商业号', icon: <WABIcon />, children: <InputComposer currentActive={activeChannel==='waba'} channel={'waba'} /> },
{ key: 'waba', label: mobile ? '' : `商业号(${WABAccountsMapped[whatsAppBusiness]?.verifiedName || '-'})`, icon: <WABIcon />, children: <InputComposer currentActive={activeChannel==='waba'} channel={'waba'} /> },
{ key: 'email', label: mobile ? '' : '邮件', icon: <MailOutlined className='text-indigo-500' />, children: <EmailComposer currentActive={activeChannel==='email'} /> },
// { key: 'whatsapp', label: mobile ? '' : 'WhatsApp', icon: <WhatsAppOutlined className='text-whatsapp' />, children: <InputComposer channel={'whatsapp'} /> },
{ 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> },

Loading…
Cancel
Save