import getRealationList from '../relations/relation.factory';

const getDefaultProps = (index = 1, template) => ({
  relation_type: 'page',
  name: `Page ${index} Name`,
  title: `Page ${index} Title`,
  meta_title: `Page ${index} Meta Title`,
  meta_description: `Page ${index} Meta Description`,
  meta_robots: ['one', 'two', 'three'],
  language: 'en',
  template_id: '1',
  path: `sport/brand/${index}`,
  url: 'https://test-site.com',
  logo_url: '#',
  banner: '313df295c19d7c5f137ceda9d0cc5df7.jpeg',
  rating: '4.88',
  sections: {
    main: {
      modules: [
        {
          value:
            "<p>'<em>'Whether it's crafting blog posts, articles, product descriptions, or marketing copy, I approach every project with the same level of passion and dedication. My ability to adapt my writing style to suit different niches and target audiences has earned me a reputation as a versatile and dependable writer</em>.''</p>",
          name: 'content',
        },
        {
          mode: 'image_text',
          show_read_more: null,
          read_more_text: null,
          items: [Array],
          module_value_id: 401446,
          name: 'spotlights',
        },
        {
          cards_page_type: null,
          cards_page_type_id: null,
          cards_selector: 'use_filters',
          cards_selector_manual_list: [],
          cards_selector_filters_limit: null,
          cards_selector_filters: [Object],
          cards_selector_filters_sort_by: 'latest',
          cards_enable_pagination: false,
          module_value_id: 401448,
          name: 'cards_v2',
          anchored: 0,
        },
        {
          value_id: 309998,
          value_type: 'prefilled_module_market',
          anchor_label: null,
          anchor_slug: null,
          module_value_id: 401447,
        },
      ],
      extra_fields: {
        logos: { value: 339, type: 'default' },
      },
    },
  },
  extra_fields: { related_operator: {} },
  breadcrumbs: [{ label: 'Sport', path: 'sport' }],
  preconnect_links: ['1', '2', '3'],
  robot_options: { page_index: 1 },
  seo_json_schema: ['custom_json_schema'],
  relation_id: 1,
  relation: getRealationList({ template })[1],
});

const getTemplateProps = (template) =>
  ({
    operator: {
      relation_type: 'operator',
    },
    game: {
      relation_type: 'game',
    },
    author: {
      relation_type: 'author',
    },
  }[template] || {});

export default function getPageList({ template = 'page', count = 1, id = 1, ...customProps } = {}) {
  const pageList = [];
  // eslint-disable-next-line no-plusplus
  for (let index = id; index < id + count; index++) {
    pageList.push({
      id: index,
      ...getDefaultProps(index, template),
      ...getTemplateProps(template),
      ...customProps,
    });
  }
  return pageList;
}
