perf: 更新模板的排序

dev/emitter
Lei OT 10 months ago
parent 9166a12215
commit e993f4195a

@ -12,13 +12,28 @@ 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' && _t.name !== 'say_hello_from_trip_advisor')
.map((ele) => ({ ...ele, components_origin: ele.components, components: groupBy(ele.components, (_c) => _c.type.toLowerCase()) }));
const topName = ['free_style_7', 'online_inquiry_received','say_hello_again', 'first_message_for_not_reply', 'free_style_2', 'free_style_1', 'free_style_3', 'free_style_4'];
.filter((_t) => _t.status === 'APPROVED' && !['say_hello_from_trip_advisor','free_style_7','free_style_1'].includes(_t.name))
.map((ele, i) => ({ ...ele, components_origin: ele.components, components: groupBy(ele.components, (_c) => _c.type.toLowerCase()), key:ele.name, }));
const topName = [
'order_updated_specialist_assigned_sharon',
'online_inquiry_received',
'say_hello_again',
'first_message_for_not_reply',
'order_updated_specialist_assigned_christy',
'free_style_2',
'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];
};
/**
* 上面的模板名称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
*/
export const CONVERSATION_PAGE_SIZE = 20;
/**

@ -108,17 +108,21 @@ const CategoryList = ({ dataSource, handleSendTemplate, valueMapped, onInput, ac
className=' h-[90%] overflow-y-auto text-slate-900'
itemLayout='horizontal'
dataSource={dataSource}
rowKey={'name'}
rowKey={'key'}
pagination={dataSource.length < 4 ? false : { position: 'bottom', pageSize: 3, align: 'start', size: 'small' }}
renderItem={(item, index) => (
<List.Item key={`${currentConversation.sn}_${item.name}`}>
<List.Item key={`${currentConversation.sn}_${item.key}`}>
<List.Item.Meta
className=' '
title={
<Flex justify={'space-between'}>
<span>{item.components.header?.[0]?.text || item.name}<Tag style={{...TagColorStyle(item.language.toUpperCase(), true)}} className='ml-1'>{item.language.toUpperCase()}</Tag>
<span>
{item.components.header?.[0]?.text || (item.name.includes('specialist') ? `specialist_followup` : item.name)}
<Tag style={{ ...TagColorStyle(item.language.toUpperCase(), true) }} className='ml-1'>
{item.language.toUpperCase()}
</Tag>
{/* <Tag style={{...TagColorStyle(item.category.toUpperCase(), true)}}>{templateCaterogyText[item.category]}</Tag> */}
{templateCaterogyTipText[item.category] && <Tag style={{...TagColorStyle(item.category.toUpperCase(), true)}}>{templateCaterogyTipText[item.category]}</Tag>}
{templateCaterogyTipText[item.category] && <Tag style={{ ...TagColorStyle(item.category.toUpperCase(), true) }}>{templateCaterogyTipText[item.category]}</Tag>}
</span>
<Button onClick={() => handleSendTemplate(item)} size={'small'} type='link' key={'send'} icon={<SendOutlined />}>
Send
@ -138,7 +142,8 @@ const CategoryList = ({ dataSource, handleSendTemplate, valueMapped, onInput, ac
/>
</List.Item>
)}
/>)
/>
)
}
const InputTemplate = ({ disabled = false, invokeSendMessage }) => {

Loading…
Cancel
Save