<template>
    <v-layout row wrap>
        <zoznam
                :zoznam="zoznamNajnovsichUcebnychMaterialov"
                :loading="loading"
        >
            <v-flex xs12 slot="hlavicka">
                <v-subheader px-0>Najnovšie učebné materiály</v-subheader>
            </v-flex>
        </zoznam>
    </v-layout>
</template>

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

  export default {
    name: 'PlochaPageView',
    components: {
      Zoznam,
    },
    data() {
      return {}
    },
    computed: {
      ...mapState('kniznica', [
        'ucebneMaterialy'
      ]),
      zoznamNajnovsichUcebnychMaterialov () {
        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: {
            limit: 3,
          },
          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()
    },
  }
</script>

<style scoped>

</style>
