<template>
  <Page
    :back="{
      href: {
        name: 'ClubsNewsListingPage',
        params: { slug: $route.params.clubs_slug }
      }
    }"
    :fields="fields"
    :contentOptions="{
      categoriesConfig
    }"
    :related-options="{
      extraFilters: relatedExtraFilters,
      title: 'Autres actualités du club',
      componentAttributes: item => ({
        to: {
          name: 'ClubsNewsPage',
          params: { slug: $route.params.slug, news_clubs_slug: item.slug[0] }
        }
      })
    }"
    contentType="clubs_news"
    config-module="inside-customs"
  />
</template>

<script>
import Page from '@inside-news/components/pages/NewsPage'

export default {
  name: 'ClubsNewsPage',
  components: { Page },
  data() {
    return {
      categoriesConfig: {
        news_categories: {
          data: (data, contentType, { getData }) => getData(data, contentType),
          disabledOn: ['ClubsNewsListingPage', 'ClubsPage', 'ClubsNewsPage']
        }
      }
    }
  },
  computed: {
    fields() {
      return [
        'chapo',
        'content',
        'image',
        'admin',
        {
          reactions: [
            'count',
            {
              users: ['uuid', 'lastname', 'firstname', 'image']
            }
          ]
        },
        'title',
        'content_type',
        'slug',
        'uuid',
        'updated_at',
        'created_at',
        'published_at',
        {
          news_categories: ['title', 'uuid', 'slug']
        },
        'article_chapo',
        'article_image',
        {
          clubs: ['slug', 'title']
        },
        { comments: { fields: ['count'] } },
        'uuid'
      ]
    },
    relatedExtraFilters() {
      return {
        clubs: { 'slug:eq': this.$route.params.clubs_slug }
      }
    }
  }
}
</script>
