<script>
import { h } from 'vue'

import { withFetch } from 'inside-collection/hocs'

import { http } from '@inside-library/helpers/Http'

import DashboardSummaryContainer from '../components/dashboard/summary/DashboardSummaryContainer.vue'

const fetchParentFolders = async () => {
  try {
    const { data } = await http.get('content/folders', {
      filters: {
        pid: null,
        sort: 'weight:asc'
      },
      fields: ['title', 'content_type', 'slug', 'uuid', 'uuid']
    })
    return data
  } catch (err) {
    throw new Error(err)
  }
}

export default {
  name: 'DashboardSummaryPage',
  render() {
    const DashboardSummary = withFetch(DashboardSummaryContainer, {
      size: 'xxl'
    })(fetchParentFolders)

    return h(DashboardSummary)
  }
}
</script>
