import {SelectedItemsState} from './interfaces';

export const prepareSelectedItems = (state: SelectedItemsState) => {
  return Array.from(state.values()).reduce<{
    destinationChannelIds: string[];
    destinationUserIds: number[];
  }>(
    (acc, {id, isUser}) => {
      if (isUser) {
        acc.destinationUserIds.push(+id);
      } else {
        acc.destinationChannelIds.push(id);
      }
      return acc;
    },
    {destinationChannelIds: [], destinationUserIds: []},
  );
};
