<template>
    <div class="dataTableFooter">
        <div class="dataTableFooter__info">
            Showing {{ startIndex + 1 }} to {{ Math.min(endIndex, totalCount) }} of {{ totalCount }} results
        </div>
        <div class="dataTableFooter__pagination">
            <button
                class="dataTableFooter__btn"
                :disabled="currentPage === 1"
                @click="$emit('change-page', currentPage - 1)"
            >
                Previous
            </button>

            <button
                v-for="page in totalPages"
                :key="page"
                :class="['dataTableFooter__btn', { 'dataTableFooter__btn--active': currentPage === page }]"
                @click="$emit('change-page', page)"
            >
                {{ page }}
            </button>

            <button
                class="dataTableFooter__btn"
                :disabled="currentPage === totalPages || totalPages === 0"
                @click="$emit('change-page', currentPage + 1)"
            >
                Next
            </button>
        </div>
    </div>
</template>

<script>
export default {
    name: 'DataTableFooter',
    props: {
        startIndex: { type: Number, required: true },
        endIndex: { type: Number, required: true },
        totalCount: { type: Number, required: true },
        currentPage: { type: Number, required: true },
        totalPages: { type: Number, required: true }
    }
};
</script>

<style lang="less" scoped>
@import "../../../../styles/admin/elements/table/footer.less";
</style>
