|
|
|
@ -9,6 +9,7 @@ import { isEmpty } from '@/utils/utils';
|
|
|
|
|
import { v4 as uuid } from 'uuid';
|
|
|
|
|
import { sentMsgTypeMapped } from '@/lib/msgUtils';
|
|
|
|
|
import InputTemplate from './InputTemplate';
|
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
|
|
const InputBox = () => {
|
|
|
|
|
const { loginUser } = useAuthContext();
|
|
|
|
@ -19,6 +20,8 @@ const InputBox = () => {
|
|
|
|
|
|
|
|
|
|
const talkabled = !isEmpty(currentConversation.sn) && websocketOpened;
|
|
|
|
|
|
|
|
|
|
const gt24h = currentConversation.last_received_time ? dayjs().diff(dayjs(currentConversation.last_received_time), 'hour') > 24 : true;
|
|
|
|
|
|
|
|
|
|
const invokeSendMessage = (msgObj) => {
|
|
|
|
|
console.log('sendMessage------------------', msgObj);
|
|
|
|
|
const contentToSend = sentMsgTypeMapped[msgObj.type].contentToSend(msgObj);
|
|
|
|
@ -49,9 +52,9 @@ const InputBox = () => {
|
|
|
|
|
<div>
|
|
|
|
|
<Input.TextArea
|
|
|
|
|
size='large'
|
|
|
|
|
placeholder='Enter for Send, Shift+Enter for new line'
|
|
|
|
|
placeholder={gt24h ? 'The session has expired, please send a template message to say hello' : 'Enter for Send, Shift+Enter for new line'}
|
|
|
|
|
rows={2}
|
|
|
|
|
disabled={!talkabled}
|
|
|
|
|
disabled={!talkabled || gt24h}
|
|
|
|
|
value={textContent}
|
|
|
|
|
onChange={(e) => setTextContent(e.target.value)}
|
|
|
|
|
className='rounded-b-none'
|
|
|
|
@ -67,7 +70,7 @@ const InputBox = () => {
|
|
|
|
|
<Flex gap={4} className='divide-y-0 divide-x divide-solid divide-gray-500 '>
|
|
|
|
|
<InputTemplate key='templates' disabled={!talkabled} invokeSendMessage={invokeSendMessage} />
|
|
|
|
|
</Flex>
|
|
|
|
|
<Button key={'send-btn'} onClick={handleSendText} type='primary' size='middle' icon={<SendOutlined />} disabled={!talkabled}>
|
|
|
|
|
<Button key={'send-btn'} onClick={handleSendText} type='primary' size='middle' icon={<SendOutlined />} disabled={!talkabled || gt24h}>
|
|
|
|
|
Send
|
|
|
|
|
</Button>
|
|
|
|
|
</Flex>
|
|
|
|
|