|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
|
|
|
|
|
import { groupBy, pick } from '@/utils/utils';
|
|
|
|
|
import { groupBy, pick, sortArrayByOrder } from '@/utils/utils';
|
|
|
|
|
import { fetchJSON, postJSON } from '@/utils/request'
|
|
|
|
|
import { parseRenderMessageList } from '@/lib/msgUtils';
|
|
|
|
|
import { API_HOST } from '@/config';
|
|
|
|
@ -11,7 +11,10 @@ export const fetchTemplates = async () => {
|
|
|
|
|
const canUseTemplates = (data?.result?.items || [])
|
|
|
|
|
.filter((_t) => _t.status !== 'REJECTED')
|
|
|
|
|
.map((ele) => ({ ...ele, components_origin: ele.components, components: groupBy(ele.components, (_c) => _c.type.toLowerCase()) }));
|
|
|
|
|
return canUseTemplates;
|
|
|
|
|
const topName = ['say_hello_from_trip_advisor', 'free_style_7', 'free_style_2', 'free_style_1', '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];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|