|
|
@ -12,15 +12,42 @@ import dayjs from 'dayjs';
|
|
|
|
export const fetchTemplates = async (params) => {
|
|
|
|
export const fetchTemplates = async (params) => {
|
|
|
|
const data = await fetchJSON(`${API_HOST}/listtemplates`, params);
|
|
|
|
const data = await fetchJSON(`${API_HOST}/listtemplates`, params);
|
|
|
|
const topName = [
|
|
|
|
const topName = [
|
|
|
|
'order_updated_specialist_assigned_sharon',
|
|
|
|
'agent_intro_with_update_v1',
|
|
|
|
'online_inquiry_received',
|
|
|
|
'online_inquiry_received',
|
|
|
|
'say_hello_again',
|
|
|
|
'say_hello_again',
|
|
|
|
'first_message_for_not_reply',
|
|
|
|
|
|
|
|
'order_updated_specialist_assigned_christy',
|
|
|
|
'order_updated_specialist_assigned_christy',
|
|
|
|
'order_resumed_specialist_followup_schedule_sharon',
|
|
|
|
'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_3',
|
|
|
|
// 'free_style_4',
|
|
|
|
// '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 || [])
|
|
|
|
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))
|
|
|
|
.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) => ({
|
|
|
|
.map((ele, i) => ({
|
|
|
@ -28,7 +55,9 @@ export const fetchTemplates = async (params) => {
|
|
|
|
components_origin: ele.components,
|
|
|
|
components_origin: ele.components,
|
|
|
|
components: groupBy(ele.components, (_c) => _c.type.toLowerCase()),
|
|
|
|
components: groupBy(ele.components, (_c) => _c.type.toLowerCase()),
|
|
|
|
key: ele.name,
|
|
|
|
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));
|
|
|
|
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 = {
|
|
|
|
const templatesDisplayNameMap = {
|
|
|
|
'order_updated_specialist_assigned_sharon': 'specialist_followup',
|
|
|
|
'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',
|
|
|
|
'online_inquiry_received': 'online_inquiry_received/say_hello',
|
|
|
|
'order_resumed_specialist_followup_schedule_sharon': 'order_resumed/specialist_followup',
|
|
|
|
'order_resumed_specialist_followup_schedule_sharon': 'order_resumed/specialist_followup',
|
|
|
|
'order_updated': 'specialist_followup',
|
|
|
|
'order_updated': 'specialist_followup',
|
|
|
|
|
|
|
|
'agent_intro_with_update_v1': 'quick_update_v1',
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export const CONVERSATION_PAGE_SIZE = 50;
|
|
|
|
export const CONVERSATION_PAGE_SIZE = 50;
|
|
|
@ -84,7 +114,7 @@ export const fetchConversationsList = async (params) => {
|
|
|
|
customer_name: `${ele.whatsapp_name || ''}`.trim(),
|
|
|
|
customer_name: `${ele.whatsapp_name || ''}`.trim(),
|
|
|
|
whatsapp_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 || '',
|
|
|
|
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,
|
|
|
|
top_state: ele.top_state || 0,
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|