From 461ed80ecb9a88499d2278104252e5b3d3dd447c Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 18 Apr 2025 09:20:58 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=96=B0=E6=A8=A1=E6=9D=BF=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/actions/ConversationActions.js | 40 ++++++++++++++++--- .../Conversations/Online/Input/Template.jsx | 5 ++- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/actions/ConversationActions.js b/src/actions/ConversationActions.js index 3c22f8c..c11044c 100644 --- a/src/actions/ConversationActions.js +++ b/src/actions/ConversationActions.js @@ -12,15 +12,42 @@ import dayjs from 'dayjs'; export const fetchTemplates = async (params) => { const data = await fetchJSON(`${API_HOST}/listtemplates`, params); const topName = [ - 'order_updated_specialist_assigned_sharon', + 'agent_intro_with_update_v1', 'online_inquiry_received', 'say_hello_again', - 'first_message_for_not_reply', 'order_updated_specialist_assigned_christy', 'order_resumed_specialist_followup_schedule_sharon', + 'travel_service_update_v1', + 'order_updated_specialist_assigned_sharon', + 'first_message_for_not_reply', // 'free_style_3', // 'free_style_4', ]; + // shouwcase + const scNames = ['trip_planner_showcase', 'showcase_different', 'order_status_updated']; + // 客运 + const crNames = [ + 'notification_of_one_day_before_ending_the_trip_by_cr_v2', + 'post_booking_confirmation_welcome', + 'notification_of_status_changed', + 'birthday_greetings_by_customer_relations_0', + 'post_trip_voucher_issued', + 'account_updated_order_ref', + 'post_trip_account_updated_from_cr', + 'post_trip_account_updated', + 'account_update_birthday', + 'post_trip_birthday_reward', + 'birthday_greetings_by_customer_relations_2', + 'birthday_greetings_by_customer_relations_1', + 'notification_of_account_updated_by_cr', + 'notification_of_one_day_before_ending_the_trip_by_cr', + 'birthday_greetings_by_customer_relations', + 'one_day_before_ending_the_trip_by_customer_relations', + 'one_day_after_payment_by_customer_relations', + 'birthday_greetings_by_marketing', 'one_day_before_ending_the_trip_by_marketing', + 'one_day_after_payment_by_yuni', 'introduce_the_voucher_one_day_before_ending_the_trip_by_marketing', + 'one_day_before_ending_the_trip_contacted_by_yuni', 'one_day_before_ending_the_trip_first_time_by_yuni' + ] const canUseTemplates = (data?.result?.items || []) .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) => ({ @@ -28,7 +55,9 @@ export const fetchTemplates = async (params) => { components_origin: ele.components, components: groupBy(ele.components, (_c) => _c.type.toLowerCase()), key: ele.name, - displayName: ele.name.startsWith('order_updated') ? templatesDisplayNameMap['order_updated'] : templatesDisplayNameMap?.[ele.name] || ele.name, + // displayName: ele.name.startsWith('order_updated') ? templatesDisplayNameMap['order_updated']+`_${i}` : templatesDisplayNameMap?.[ele.name] || ele.name, + displayName: templatesDisplayNameMap?.[ele.name] || (ele.name.startsWith('order_updated') ? templatesDisplayNameMap['order_updated']+`_${i}` : ele.name), + displayLanguage: crNames.includes(ele.name) ? ele.language + '-客运' : scNames.includes(ele.name) ? ele.language + '-示例' : ele.language, })) const top2Name = topName.concat(canUseTemplates.filter(_t => _t.name.startsWith('order_updated')).map(_tem => _tem.name)); @@ -48,10 +77,11 @@ export const fetchTemplates = async (params) => { */ const templatesDisplayNameMap = { 'order_updated_specialist_assigned_sharon': 'specialist_followup', - 'order_updated_specialist_assigned_christy': 'specialist_followup', + 'order_updated_specialist_assigned_christy': 'specialist_followup_1', 'online_inquiry_received': 'online_inquiry_received/say_hello', 'order_resumed_specialist_followup_schedule_sharon': 'order_resumed/specialist_followup', 'order_updated': 'specialist_followup', + 'agent_intro_with_update_v1': 'quick_update_v1', }; export const CONVERSATION_PAGE_SIZE = 50; @@ -84,7 +114,7 @@ export const fetchConversationsList = async (params) => { customer_name: `${ele.whatsapp_name || ''}`.trim(), whatsapp_name: `${ele.whatsapp_name || ''}`.trim(), show_default: ele.conversation_memo || ele.whatsapp_name || ele?.channels?.whatsapp_phone_number || ele?.channels?.phone_number || ele?.channels?.email || '', - coli_id: ele.COLI_ID, + // coli_id: ele.COLI_ID, top_state: ele.top_state || 0, })) return list; diff --git a/src/views/Conversations/Online/Input/Template.jsx b/src/views/Conversations/Online/Input/Template.jsx index f1e9e96..5c9387f 100644 --- a/src/views/Conversations/Online/Input/Template.jsx +++ b/src/views/Conversations/Online/Input/Template.jsx @@ -179,12 +179,13 @@ const InputTemplate = ({ disabled = false, invokeSendMessage, channel }) => { const [searchContent, setSearchContent] = useState(''); // 用于替换变量: customer, agent - const valueMapped = { ...cloneDeep(currentConversation), ...objectMapper(loginUser, { usernameEN: [{ key: 'agent_name' }, { key: 'your_name' }, { key: 'your_name1' }, { key: 'your_name2' }] }) }; + const valueMapped = { ...cloneDeep(currentConversation), ...objectMapper(loginUser, { usernameEN: [{ key: 'agent_name' }, { key: 'your_name' }, { key: 'your_name1' }, { key: 'your_name2' }] }), ...{ order_number: currentConversation.coli_id } }; + console.log(valueMapped); useEffect(() => { setDataSource([]); // setDataSource(templates); const mappedByCategory = groupBy(templates, 'category'); - const mappedByLang = sortObjectsByKeysMap(groupBy(templates, 'language'), ['en']); // todo: 按账户语种排序 + const mappedByLang = sortObjectsByKeysMap(groupBy(templates, 'displayLanguage'), ['en']); // todo: 按账户语种排序 setTemplateCMapped(mappedByCategory); setTemplateLangMapped(mappedByLang); return () => {};