<template>
  <Block :title="$_tr('title')" title-tag="h3">
    <GroupWithTabs
      :categories-filters="categoriesFilters"
      :content-filters="contentFilters"
      :links-fetched-callback="linksFetchedCallback"
      categories-content-type="spaces_pages_categories"
      links-content-type="spaces_pages"
      space-content-type="spaces"
    />
  </Block>
</template>

<script>
import Block from '@inside-commons/components/lib/Block'

import GroupWithTabs from '@inside-links/components/lib/GroupWithTabs'

export default {
  name: 'SpacesGroupWithTabs',
  $_i18nRootPath: 'customs.SPACES.informations',
  components: {
    Block,
    GroupWithTabs
  },
  data() {
    return {
      contentFilters: { 'status:eq': 1, sort: 'weight:asc' }
    }
  },
  computed: {
    categoriesFilters() {
      return {
        'status:eq': 1,
        sort: 'weight:asc',
        spaces: { 'slug:eq': this.$route.params.slug }
      }
    }
  },
  methods: {
    linksFetchedCallback(data) {
      return data.map(item => ({
        ...item,
        link: {
          name: 'SpacesPagesPage',
          params: {
            slug: item.slug[0]
          },
          query: {
            space: this.$route.params.slug
          }
        }
      }))
    }
  }
}
</script>
