<template>
  <VisitReport class="visit-report-page-container" />
</template>

<script>
import { withFetch } from 'inside-collection/hocs'
import { http } from '@inside-library/helpers/Http'

import VisitReportContainer from '../../components/spaces/VisitReportContainer'

const fetchVisitReport = async ({ $route }) => {
  try {
    const { data } = await http.get('content/visit_report', {
      fields: [
        'uuid',
        'title',
        'slug',
        'admin',
        'content_type',
        'updated_at',
        'content',
        { comments: ['count'] },
        { franchised_spaces: ['uuid', 'title', 'slug'] },
        {
          authors: [
            'lastname',
            'firstname',
            'image',
            'function',
            'phone',
            'uuid',
            'users_status'
          ]
        }
      ],
      filters: { 'slug:eq': $route.params.rapport }
    })

    return data[0]
  } catch (err) {
    throw new Error(err)
  }
}

export default {
  name: 'VisitReportPage',
  components: {
    VisitReport: withFetch(VisitReportContainer, { size: 'xxl' })(
      fetchVisitReport
    )
  }
}
</script>

<style></style>
