|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import React, { useState, useRef, useEffect } from 'react';
|
|
|
|
|
import { App, Input, Flex, Button, Image, Tooltip } from 'antd';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
// import { Input } from 'react-chat-elements';
|
|
|
|
|
import useAuthStore from '@/stores/AuthStore';
|
|
|
|
|
import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
|
@ -25,12 +26,13 @@ const ButtonStyleClsMapped =
|
|
|
|
|
{
|
|
|
|
|
'waba': 'bg-waba shadow shadow-waba-300 hover:!bg-waba-400 active:bg-waba-400 focus:bg-waba-400',
|
|
|
|
|
'whatsapp': 'bg-whatsapp shadow shadow-whatsapp-300 hover:!bg-whatsapp-400 active:bg-whatsapp-400 focus:bg-whatsapp-400',
|
|
|
|
|
'wa': 'bg-whatsapp shadow shadow-whatsapp-300 hover:!bg-whatsapp-400 active:bg-whatsapp-400 focus:bg-whatsapp-400',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const InputComposer = ({ isWABA, channel }) => {
|
|
|
|
|
const InputComposer = ({ channel }) => {
|
|
|
|
|
const [mobile] = useStyleStore((state) => [state.mobile]);
|
|
|
|
|
|
|
|
|
|
const userId = useAuthStore((state) => state.loginUser.userId);
|
|
|
|
|
const {userId, whatsAppBusiness} = useAuthStore((state) => state.loginUser);
|
|
|
|
|
const [openPaymentDrawer] = useOrderStore((state) => [state.openDrawer])
|
|
|
|
|
|
|
|
|
|
const websocket = useConversationStore((state) => state.websocket);
|
|
|
|
|
@ -62,6 +64,24 @@ const InputComposer = ({ isWABA, channel }) => {
|
|
|
|
|
? 'Enter 发送, Shift+Enter 换行'
|
|
|
|
|
: 'Enter 换行';
|
|
|
|
|
|
|
|
|
|
const [fromIM, setFromIM] = useState('');
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
switch (channel) {
|
|
|
|
|
case 'waba':
|
|
|
|
|
setFromIM(whatsAppBusiness)
|
|
|
|
|
break
|
|
|
|
|
case 'wa':
|
|
|
|
|
setFromIM('') // todo: 个人WhatsApp号
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return () => {}
|
|
|
|
|
}, [channel, whatsAppBusiness])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const textInputRef = useRef(null);
|
|
|
|
|
const [textContent, setTextContent] = useState('');
|
|
|
|
|
|
|
|
|
|
@ -70,6 +90,7 @@ const InputComposer = ({ isWABA, channel }) => {
|
|
|
|
|
sender: 'me',
|
|
|
|
|
senderName: 'me',
|
|
|
|
|
to: currentConversation.whatsapp_phone_number,
|
|
|
|
|
from: fromIM,
|
|
|
|
|
date: new Date(),
|
|
|
|
|
status: 'waiting',
|
|
|
|
|
...(referenceMsg.id ? { context: { message_id: referenceMsg.id }, message_origin: referenceMsg } : {}),
|
|
|
|
|
@ -114,6 +135,7 @@ const InputComposer = ({ isWABA, channel }) => {
|
|
|
|
|
sender: 'me',
|
|
|
|
|
senderName: 'me',
|
|
|
|
|
to: currentConversation.whatsapp_phone_number,
|
|
|
|
|
from: fromIM,
|
|
|
|
|
date: new Date(),
|
|
|
|
|
status: 'waiting',
|
|
|
|
|
...(referenceMsg.id ? { context: { message_id: referenceMsg.id }, message_origin: referenceMsg } : {}),
|
|
|
|
|
@ -331,4 +353,6 @@ const InputComposer = ({ isWABA, channel }) => {
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
InputComposer.PropTypes = { channel: PropTypes.oneOf(['waba', 'wa']) };
|
|
|
|
|
|
|
|
|
|
export default InputComposer;
|
|
|
|
|
|