import { ALIAS, MAIN } from '../constants';

export const isAliasDialogButtonDisabled = (keywords) => {
  if (!keywords || !keywords.length) return true;

  if (keywords.some((item) => !item.value)) return true;

  // Check for each ALIAS if there is a corresponding MAIN for the same language
  const aliasLanguages = keywords.filter((item) => item.status === ALIAS).map((item) => item.lang);
  const mainLanguages = new Set(keywords.filter((item) => item.status === MAIN).map((item) => item.lang));

  return aliasLanguages.some((lang) => !mainLanguages.has(lang));
};
