import type { ContactInfo } from 'tuikit-atomicx-react/chat'; import { getFriendDisplayName } from './contactName'; import { sortByFirstChar } from './sortByFirstChar'; import type { ContactLetterSection } from '../../../types/contact'; export function buildFriendSections(friendList: ContactInfo[]): ContactLetterSection[] { const { groupedList } = sortByFirstChar(friendList, getFriendDisplayName); return Object.entries(groupedList).map(([letter, items]) => ({ key: letter, title: letter, count: items.length, items, })); }