From 85d43d460be8fd90f0e0468fc631b4e5699bc983 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 5 Feb 2024 15:43:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20Link=E3=80=81Location?= =?UTF-8?q?=20=E4=BC=A0=E9=80=92=E5=AF=B9=E8=B1=A1=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Conversations/Components/CustomerProfile.jsx | 3 +++ src/views/OrderFollow.jsx | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/views/Conversations/Components/CustomerProfile.jsx b/src/views/Conversations/Components/CustomerProfile.jsx index 568e053..eb1a11d 100644 --- a/src/views/Conversations/Components/CustomerProfile.jsx +++ b/src/views/Conversations/Components/CustomerProfile.jsx @@ -1,6 +1,7 @@ import { Card, Flex, Avatar, Typography, Radio, Button, Table } from 'antd'; import { useAuthContext } from '@/stores/AuthContext.js'; import { useConversationState } from '@/stores/ConversationContext'; +import { useLocation } from 'react-router-dom' import { HomeOutlined, LoadingOutlined, SettingFilled, SmileOutlined, SyncOutlined, PhoneOutlined, MailOutlined, WhatsAppOutlined, SmileTwoTone } from '@ant-design/icons'; import CreatePayment from './CreatePayment'; @@ -22,6 +23,8 @@ const orderStatus = [ const { Meta } = Card; const CustomerProfile = (({ colisn }) => { + let { state } = useLocation() + console.info(state) console.log('invoke customer profile+++++++++++++++++++++++++++++++++++++++++++++', colisn); const { customerOrderProfile: orderInfo } = useConversationState(); const { loginUser: currentUser } = useAuthContext(); diff --git a/src/views/OrderFollow.jsx b/src/views/OrderFollow.jsx index 237b96a..afd8f2d 100644 --- a/src/views/OrderFollow.jsx +++ b/src/views/OrderFollow.jsx @@ -3,7 +3,7 @@ import { Radio, Row, Col, Select, Space, Switch, Table, Tag } from 'antd' import { memo, useCallback, useEffect, useState } from 'react' -import { NavLink } from 'react-router-dom' +import { Link } from 'react-router-dom' import dayjs from 'dayjs' import { Conditional } from '@/components/Conditional' import { useAuthContext } from '@/stores/AuthContext' @@ -164,7 +164,7 @@ function OrderList({ formValues }) { if (record.buytime > 0) regularText = '(R' + record.buytime + ')' return ( - {text + regularText} + {text + regularText} Date: Mon, 5 Feb 2024 16:52:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/OrderFollow.jsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/views/OrderFollow.jsx b/src/views/OrderFollow.jsx index afd8f2d..507efa6 100644 --- a/src/views/OrderFollow.jsx +++ b/src/views/OrderFollow.jsx @@ -1,6 +1,6 @@ import { App, Badge, Button, DatePicker, Divider, Flex, Form, Input, - Radio, Row, Col, Select, Space, Switch, Table, Tag + Radio, Row, Col, Select, Space, Switch, Table, Tag, Collapse } from 'antd' import { memo, useCallback, useEffect, useState } from 'react' import { Link } from 'react-router-dom' @@ -318,7 +318,24 @@ function OrderFollow() { /> - + + }, + { + key: '2', + label: 'CH 订单:25', + children: + }, + { + key: '3', + label: 'GH 订单:25', + children: + }, + ]} + /> ) } From d7d13108a0a01ba7bb5eddf88a9e50c75dcc5f20 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 5 Feb 2024 16:59:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=85=B3=E9=97=AD=E4=BC=9A=E8=AF=9D:=20?= =?UTF-8?q?=E4=BC=A0=E5=8F=82;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 会话窗口刷新和获取消息记录; 引用消息 --- src/actions/ConversationActions.js | 4 +- src/lib/msgUtils.js | 6 +- src/reducers/ConversationReducer.js | 6 +- .../Components/ConversationsList.jsx | 88 ++++++------------- .../Components/InputComposer.jsx | 12 +-- .../Components/InputTemplate.jsx | 2 +- .../Conversations/Components/Messages.jsx | 4 +- .../Conversations/ConversationProvider.jsx | 5 +- 8 files changed, 49 insertions(+), 78 deletions(-) diff --git a/src/actions/ConversationActions.js b/src/actions/ConversationActions.js index 719164d..79d391b 100644 --- a/src/actions/ConversationActions.js +++ b/src/actions/ConversationActions.js @@ -111,8 +111,8 @@ export const fetchTemplates = async () => { return canUseTemplates; }; -export const fetchConversationsList = async (opisn) => { - const { result: data } = await fetchJSON(`${API_HOST}/getconversations`, { opisn }); +export const fetchConversationsList = async (params) => { + const { result: data } = await fetchJSON(`${API_HOST}/getconversations`, params); const list = data.map((ele) => ({ ...ele, customer_name: ele.whatsapp_name.trim() })); return list; }; diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index 8ab0865..8fd8da1 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -31,9 +31,9 @@ export const sentMsgTypeMapped = { renderId: msg.id, to: msg.to, msgtype: 'text', - msgcontent: { body: msg.text, ...(msg.context ? { context: msg.context } : {}) }, + msgcontent: { body: msg.text, ...(msg.context ? { context: msg.context, message_origin: msg.message_origin } : {}) }, }), - contentToRender: (msg) => ({ ...msg, actionId: msg.id, conversationid: msg.id.split('.')[0], ...(msg.context ? { reply: { message: msg.context.message_origin.text, title: msg.context.message_origin.senderName || 'Reference' } } : {}) }), + contentToRender: (msg) => ({ ...msg, actionId: msg.id, conversationid: msg.id.split('.')[0], ...(msg.context ? { reply: { message: msg.message_origin.text, title: msg.message_origin.senderName || 'Reference' } } : {}) }), }, whatsappTemplate: { contentToSend: (msg) => ({ action: 'message', actionId: msg.id, renderId: msg.id, to: msg.to, msgtype: 'template', msgcontent: msg.template }), @@ -212,6 +212,7 @@ export const parseRenderMessageItem = (msg) => { customer_name: msg?.customerProfile?.name || '', whatsapp_name: msg?.customerProfile?.name || '', whatsapp_phone_number: msg.from, + whatsapp_msg_type: msg.type, }; }; /** @@ -240,6 +241,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => { : {}), // conversationid: conversationid, // title: msg.customerProfile.name, + whatsapp_msg_type: msgContent.type, }; }); }; diff --git a/src/reducers/ConversationReducer.js b/src/reducers/ConversationReducer.js index 1917345..357a0d8 100644 --- a/src/reducers/ConversationReducer.js +++ b/src/reducers/ConversationReducer.js @@ -70,10 +70,12 @@ const ConversationReducer = (state = initialState, action) => { const message = action.payload; const targetId = message.conversationid; const targetMsgs = (activeConversations[String(targetId)] || []).map((ele) => { + // 更新状态 + // * 已读的不再更新状态, 有时候投递结果在已读之后返回 if (ele.id === ele.actionId && ele.actionId === message.actionId) { - return { ...ele, id: message.id, status: message.status, dateString: message.dateString }; + return { ...ele, id: message.id, status: ele.status === 'read' ? ele.status : message.status, dateString: message.dateString }; } else if (ele.id === message.id) { - return { ...ele, id: message.id, status: message.status, dateString: message.dateString }; + return { ...ele, id: message.id, status: ele.status === 'read' ? ele.status : message.status, dateString: message.dateString }; } return ele; }); diff --git a/src/views/Conversations/Components/ConversationsList.jsx b/src/views/Conversations/Components/ConversationsList.jsx index b6606ff..09a6be8 100644 --- a/src/views/Conversations/Components/ConversationsList.jsx +++ b/src/views/Conversations/Components/ConversationsList.jsx @@ -5,8 +5,7 @@ import { SendOutlined, MessageOutlined, SmileOutlined, PictureOutlined, CommentO import { useAuthContext } from '@/stores/AuthContext'; import { useConversationState, useConversationDispatch } from '@/stores/ConversationContext'; import { - fetchCustomerProfile, - receivedCustomerProfile, + fetchConversationsList, setCurrentConversation, addConversationList, delConversationitem, fetchConversationItemClose, @@ -16,38 +15,31 @@ import { ChatList, } from 'react-chat-elements'; import { isEmpty, pick } from '@/utils/utils'; import { v4 as uuid } from 'uuid'; -const CDropdown = () => { - const { loginUser } = useAuthContext(); - const { userId } = loginUser; - const { currentConversation } = useConversationState(); +const CDropdown = (props) => { const dispatch = useConversationDispatch(); - const handleConversationItemClose = async (item) => { - console.log('invoke close', {conversationid: item.sn, opisn: userId }); - // await fetchConversationItemClose({ conversationid: item.sn, opisn: userId }); - dispatch(delConversationitem(item)); + + const handleConversationItemClose = async () => { + await fetchConversationItemClose({ conversationid: props.sn, opisn: props.opi_sn }); + dispatch(delConversationitem(props)); }; return ( - { - switch (key) { + items: [{ key: 'close', danger: true, label: '关闭会话' }], + onClick: (e) => { + e.domEvent.stopPropagation(); + switch (e.key) { case 'close': - return handleConversationItemClose(currentConversation); + return handleConversationItemClose(); default: return; } }, }}> -