feat: 会话列表: 渠道ICON; 获取顾问的标签

2.0/email-builder
Lei OT 11 months ago
parent 2aedb1b6c0
commit 8cfd8ccc1a

@ -22,7 +22,7 @@ export const fetchTemplates = async () => {
* @param {object} params { opisn }
*/
export const fetchConversationsList = async (params) => {
const { errcode, result: data } = await fetchJSON(`${API_HOST}/getconversations`, params);
const { errcode, result: data } = await fetchJSON(`${API_HOST}/v2/getconversations`, params);
if (errcode !== 0) return [];
const list = (data || []).map((ele) => ({ ...ele, customer_name: `${ele.whatsapp_name || ''}`.trim(), whatsapp_name: `${ele.whatsapp_name || ''}`.trim() }));
return list;
@ -208,12 +208,8 @@ export const postAssignConversation = async (params) => {
* @param {object} params { opisn, }
*/
export const fetchTags = async (params) => {
return [
{ label: '已付款', key: 'p1', value: 'p1', },
{ label: '地接', key: 'p2', value: 'p2', },
]; // test:
const { errcode, result } = await fetchJSON(`${API_HOST}/opi_tags`, params);
return errcode !== 0 ? {} : result;
const { errcode, result } = await fetchJSON(`${API_HOST}/v2/get_opi_tags`, params);
return errcode !== 0 ? [] : result.map(ele => ({ label: ele.tag_label, key: ele.tag_key, value: ele.tag_key, }));
}
/**
* 会话设置标签

@ -4,7 +4,8 @@
// export const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_144';
// export const WS_URL = 'wss://p9axztuwd7x8a7.mycht.cn/whatsapp_144'; // prod: Slave
export const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_server';
export const API_HOST = 'http://202.103.68.157:8889';
// export const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_server';
export const WS_URL = 'wss://p9axztuwd7x8a7.mycht.cn/whatsapp_server'; // prod:
export const VONAGE_URL = 'https://p9axztuwd7x8a7.mycht.cn/vonage-server'; // 语音和视频接口:

@ -405,13 +405,13 @@ export const useConversationStore = create(
const conversationsList = await fetchConversationsList({ opisn: userIds });
addToConversationList(conversationsList);
const templates = await fetchTemplates();
setTemplates(templates);
// const templates = await fetchTemplates();
// setTemplates(templates);
const closedList = await fetchConversationsSearch({ opisn: userIds, session_enable: 0 });
setClosedConversationList(closedList);
// const closedList = await fetchConversationsSearch({ opisn: userIds, session_enable: 0 });
// setClosedConversationList(closedList);
const myTags = await fetchTags();
const myTags = await fetchTags({ opi_sn: userIds});
setTags(myTags);
setInitial(true);

@ -3,6 +3,10 @@ import { WhatsAppOutlined, MailOutlined } from '@ant-design/icons';
import { WABIcon, } from '@/components/Icons';
const ChannelLogo = ({channel}) => {
// if is array, get last
if (Array.isArray(channel)) {
channel = channel[channel.length - 1];
}
switch (channel) {
case 'waba':
return <WABIcon key={channel} className='text-whatsapp' />;

@ -5,7 +5,7 @@ import { CloseCircleOutlined } from '@ant-design/icons';
import { fetchConversationItemClose, fetchConversationsSearch, fetchConversationItemUnread, fetchConversationItemTop, postConversationTags, deleteConversationTags } from '@/actions/ConversationActions';
import { ChatItem } from 'react-chat-elements';
// import ConversationsNewItem from './ConversationsNewItem';
import { isEmpty, stringToColour } from '@/utils/commons';
import { flush, isEmpty, stringToColour } from '@/utils/commons';
import useConversationStore from '@/stores/ConversationStore';
import useAuthStore from '@/stores/AuthStore';
import ChannelLogo from './ChannelLogo';
@ -307,7 +307,11 @@ const ChatListItem = (({item, refreshConversationList,setListUpdateFlag,onSwitch
// String(item.sn) === String(tabSelectedConversation?.sn) ? ' bg-neutral-200' : '',
// ].join(' ')}
// statusText={<WhatsAppOutlined key={'channel'} className='text-whatsapp' />}
statusText={<ChannelLogo channel={'waba'} />}
statusText={<ChannelLogo channel={flush([
item.channels.phone_number ? 'phone' : null,
item.channels.email ? 'email' : null,
item.channels.whatsapp_phone_number ? 'waba' : null,
])} />}
statusColor={'#fff'}
onClick={() => onSwitchConversation(item)}
customStatusComponents={[

Loading…
Cancel
Save