perf: 模板free_style_2, 更新到跟进模板

2.0/wai-server
Lei OT 10 months ago
parent f5f5e6b1d5
commit fb9be9569f

@ -1,5 +1,5 @@
import { groupBy, isNotEmpty, pick, sortArrayByOrder } from '@/utils/commons';
import { groupBy, isNotEmpty, pick, sortArrayByOrder, sortBy } from '@/utils/commons';
import { fetchJSON, postJSON, postForm } from '@/utils/request'
import { parseRenderMessageList } from '@/channel/bubbleMsgUtils';
import { API_HOST } from '@/config';
@ -12,7 +12,7 @@ import dayjs from 'dayjs';
export const fetchTemplates = async (params) => {
const data = await fetchJSON(`${API_HOST}/listtemplates`, params);
const canUseTemplates = (data?.result?.items || [])
.filter((_t) => _t.status === 'APPROVED' && !['say_hello_from_trip_advisor','free_style_7','free_style_1'].includes(_t.name))
.filter((_t) => _t.status === 'APPROVED' && !['say_hello_from_trip_advisor','free_style_7','free_style_1','free_style_2'].includes(_t.name))
.map((ele, i) => ({ ...ele, components_origin: ele.components, components: groupBy(ele.components, (_c) => _c.type.toLowerCase()), key:ele.name, displayName: templatesDisplayNameMap?.[ele.name] || ele.name}));
const topName = [
'order_updated_specialist_assigned_sharon',
@ -20,24 +20,28 @@ export const fetchTemplates = async (params) => {
'say_hello_again',
'first_message_for_not_reply',
'order_updated_specialist_assigned_christy',
'free_style_2',
'free_style_3',
'free_style_4',
'order_resumed_specialist_followup_schedule_sharon',
// 'free_style_3',
// 'free_style_4',
]
const top = sortArrayByOrder( canUseTemplates.filter((_t) => topName.includes(_t.name)), 'name', topName);
const raw = canUseTemplates.filter((_t) => !topName.includes(_t.name));
return [...top, ...raw];
const second = canUseTemplates.filter(_t => _t.name.includes('free_style'));
const secondS = second.sort(sortBy('name'));
const raw = canUseTemplates.filter((_t) => !topName.includes(_t.name) && !_t.name.includes('free_style'));
return [...top, ...secondS, ...raw];
};
/**
* 上面的模板名称bak
* order_updated_specialist_assigned_sharon : free_style_7
* order_updated_specialist_assigned_christy : free_style_1
* online_inquiry_received: say_hello_from_trip_advisor
* order_resumed_specialist_followup_schedule_sharon: free_style_2
*/
const templatesDisplayNameMap = {
'order_updated_specialist_assigned_sharon': 'specialist_followup',
'order_updated_specialist_assigned_christy': 'specialist_followup',
'online_inquiry_received': 'online_inquiry_received/say_hello',
'order_resumed_specialist_followup_schedule_sharon': 'order_resumed/specialist_followup',
};
export const CONVERSATION_PAGE_SIZE = 20;

Loading…
Cancel
Save