perf: 会话缺少WhatsApp号码的提示

dev/emitter
Lei OT 10 months ago
parent b1efe7f02d
commit f22e32ebcd

@ -13,6 +13,7 @@ import { postUploadFileItem } from '@/actions/CommonActions';
import dayjs from 'dayjs';
import useStyleStore from '@/stores/StyleStore';
import ComposerTools from './ComposerTools';
import { useOrderStore, OrderLabelDefaultOptions, OrderStatusDefaultOptions } from "@/stores/OrderStore";
const ButtonStyleClsMapped =
{
@ -22,9 +23,11 @@ const ButtonStyleClsMapped =
};
const InputComposer = ({ channel, currentActive }) => {
const { message: appMessage, notification: appNotification } = App.useApp();
const [mobile] = useStyleStore((state) => [state.mobile]);
const {userId, whatsAppBusiness} = useAuthStore((state) => state.loginUser);
const [customerDetail] = useOrderStore((s) => [s.customerDetail])
const websocket = useConversationStore((state) => state.websocket);
const websocketOpened = useConversationStore((state) => state.websocketOpened);
@ -55,6 +58,7 @@ const InputComposer = ({ channel, currentActive }) => {
? 'Enter 发送, Shift+Enter 换行'
: 'Enter 换行';
const [toIM, setToIM] = useState('');
const [fromIM, setFromIM] = useState(DEFAULT_WABA);
useEffect(() => {
switch (channel) {
@ -73,15 +77,25 @@ const InputComposer = ({ channel, currentActive }) => {
return () => {}
}, [channel, whatsAppBusiness])
useEffect(() => {
const _to = currentConversation.whatsapp_phone_number || currentConversation.channel?.whatsapp_phone_number || currentConversation.channel?.phone_number // || customerDetail.whatsapp_phone_number
setToIM(_to);
return () => {}
}, [currentConversation, customerDetail])
const textInputRef = useRef(null);
const [textContent, setTextContent] = useState('');
const invokeSendMessage = (msgObj) => {
if (isEmpty(toIM)) {
appNotification.warning({ message: '缺少WhatsApp号码, 请先在会话列表右键菜单编辑联系人', placement: 'top' });
return false
}
const msgObjMerge = {
sender: 'me',
senderName: 'me',
to: currentConversation.whatsapp_phone_number,
to: toIM,
from: fromIM,
date: new Date(),
status: 'waiting',
@ -110,7 +124,7 @@ const InputComposer = ({ channel, currentActive }) => {
const msgObjMerge = {
sender: 'me',
senderName: 'me',
to: currentConversation.whatsapp_phone_number,
to: toIM,
date: new Date(),
status: 'waiting',
...(referenceMsg.id ? { context: { message_id: referenceMsg.id }, message_origin: referenceMsg } : {}),
@ -125,10 +139,14 @@ const InputComposer = ({ channel, currentActive }) => {
};
const invokeSendUploadMessage = (msgObj) => {
if (isEmpty(toIM)) {
appNotification.warning({ message: '缺少WhatsApp号码, 请先在会话列表右键菜单编辑联系人', placement: 'top' });
return false
}
const msgObjMerge = {
sender: 'me',
senderName: 'me',
to: currentConversation.whatsapp_phone_number,
to: toIM,
from: fromIM,
date: new Date(),
status: 'waiting',
@ -142,7 +160,6 @@ const InputComposer = ({ channel, currentActive }) => {
websocket.sendMessage({ ...contentToSend, opi_sn: userId, coli_sn: currentConversation.coli_sn, conversationid: currentConversation.sn, });
};
const { message: appMessage } = App.useApp();
const [pastedUploading, setPastedUploading] = useState(false);
const readPasted = async (file) => {
const fileTypeSupport = Object.keys(whatsappSupportFileTypes).find((msgType) => whatsappSupportFileTypes[msgType].types.includes(file.type));
@ -260,6 +277,7 @@ const InputComposer = ({ channel, currentActive }) => {
return (
<div>
{wabaWarning && <Alert message={wabaWarning} type="error" showIcon /> }
{isEmpty(toIM) && <Alert message="当前客人没有设置WhatsApp号码, 请先在会话列表右键菜单编辑联系人设置" type="warning" showIcon /> }
{referenceMsg.id && (
<Flex justify='space-between' className='reply-to bg-gray-100 p-1 rounded-none text-slate-500'>
<div className='flex flex-col referrer-msg border-l-3 border-y-0 border-r-0 border-slate-300 border-solid pl-2 pr-1 py-1'>

Loading…
Cancel
Save