<template>
  <GroupWithTabs
    :categories-filters="getPagesCategoriesFilters($route.params.slug)"
    :content-filters="spacePagesFilters"
    :links-fetched-callback="linksFetchedCallback"
    categories-content-type="job_pages_categories"
    links-content-type="job_pages"
    space-content-type="job_spaces"
  />
</template>

<script>
import { getPagesCategoriesFilters } from '../../helpers'

import { spacePagesFilters } from '../../constants'

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

export default {
  name: 'SpaceGroupWithTabs',
  components: { GroupWithTabs },
  props: {
    jobPagesCategories: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      spacePagesFilters,
      hasJobsGroupingPages: this.jobPagesCategories.count > 0
    }
  },
  methods: {
    getPagesCategoriesFilters,
    linksFetchedCallback(data) {
      return data.map(item => ({
        ...item,
        link: {
          name: 'JobPage',
          params: { slug: this.$route.params.slug },
          query: { page: item.uuid }
        }
      }))
    }
  }
}
</script>
