import { GroupMemberSource, Group } from 'src/types/groups';

export const isSourceSegmentation = (source: GroupMemberSource) =>
  source === GroupMemberSource.SEGMENTATION;

export const getNextGroupId = (
  currentGroupId: number,
  groupsList: Group[],
): number | null => {
  if (!groupsList || groupsList.length === 0) {
    return null;
  }

  const currentIndex = groupsList.findIndex(
    group => group.id === currentGroupId,
  );

  if (currentIndex === -1) {
    return null;
  }

  const prevIndex = currentIndex - 1;
  const nextIndex = currentIndex + 1;
  if (nextIndex < groupsList.length) {
    return groupsList[nextIndex].id;
  } else if (prevIndex >= 0) {
    return groupsList[prevIndex].id;
  }

  return null;
};

export const GROUP_DETAIL_PAGE_BANNER_DIMENSIONS = {
  WIDTH: 690,
  HEIGHT: 230,
};
