<template>
  <GalleryPage v-if="galleries && galleries.length > 0" :galleries="galleries">
  </GalleryPage>
  <NoContent v-else heading="My Galleries"
             message="My galleries are being prepared for upload, please check back soon."
  />
</template>

<script>
import GalleryPage from '@/components/GalleryPage'
import NoContent from '@/components/NoContent'

export default {
  name: 'GalleriesPage',

  components: {
    GalleryPage,
    NoContent,
  },

  data () {
    return {
      galleries: false,
    }
  },

  head () {
    return {
      title: 'My Galleries',
      meta: [{ 
        hid: 'description',
        name: 'description',
        content: 'A showcase of the work of photographer Marc Leopold.'
      }],
    }
  },

  async asyncData ({ $axios }) {
    try {
      let { galleries } = await $axios.$get('/api/v1/galleries')
      return { galleries }
    } catch {
      return {
        galleries: []
      }
    }
  },
}
</script>
