<template>
    <zoznam-ucebnych-materialov-component
            :zoznam="zoznamUcebnychMaterialov"
            :loading="loading"
    ></zoznam-ucebnych-materialov-component>
</template>

<script>
  import { mapActions, mapState } from 'vuex'
  import ZoznamUcebnychMaterialovComponent from '../../../components/UcebneMaterialy/Zoznam'

  export default {
    name: 'ZoznamUcebnychMaterialovPageView',
    components: {
      ZoznamUcebnychMaterialovComponent,
    },
    props: {},
    data() {
      return {}
    },
    computed: {
      ...mapState('kniznica', [
        'ucebneMaterialy'
      ]),
      zoznamUcebnychMaterialov () {
        return this.ucebneMaterialy.ucebneMaterialy
      },
      loading: function () {
        return this.ucebneMaterialy.pending.ucebnyMaterial || this.ucebneMaterialy.pending.ucebneMaterialy
      }
    },
    methods: {
      ...mapActions('kniznica/ucebneMaterialy', [
        'ziskajUcebneMaterialy',
      ]),
      ziskatZoznamUcebnychTextov (filter = {}) {
        let self = this

        const params = {
          filter: {
            'kategoria_id': this.$route.params.kategoria_id,
          },
          include: 'kategoria',
          page: filter.page || 1,
          limit: filter.rowsPerPage || 2,
          sort: '-updated_at',
        }

        this.ziskajUcebneMaterialy({
          params: params
        }).then((response) => {
          // self.totalItems = response.data.meta.total
          // self.perPageItems = response.data.meta.per_page
        }).catch((error) => {

        })
      }
    },
    mounted () {
      this.ziskatZoznamUcebnychTextov()
    },
    watch: {},
  }
</script>

<style scoped></style>
