import { getExtraField } from 'gatsby-core-theme/src/helpers/getters';

const getOperatorForSummary = (page) => {
  switch (page.relation_type) {
    case 'operator':
      return page?.relation
        ? [page?.relation, getExtraField(page.extra_fields, 'operator_review_summary', null)]
        : null;
    case 'game':
      // eslint-disable-next-line no-case-declarations
      const operator = getExtraField(page.extra_fields, 'game_review_summary_operator', null);
      return operator
        ? [operator, getExtraField(page.extra_fields, 'game_review_summary', null)]
        : null;
    default:
      return null;
  }
};

export default getOperatorForSummary;
