<template>
    <div class="row">
        <div class="col">
            <div class="row">
                <div class="col">
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>Date</th>
                                <th>Label</th>
                                <th>Reference</th>
                                <th>type</th>
                                <th>Bank</th>
                                <th>Marking</th>
                                <th>Amount</th>
                            </tr>
                            </thead>
                            <tbody>
                            <urgent-transaction-component v-for="item in list" v-bind:key="item.id" :data="item"></urgent-transaction-component>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col">
                    <div class="col-auto b-a p-t-5 p-b-5 m-l-5 pointer b-grey pointer" v-for="n in pagination.last_page" @click="fetchList(n)">
                        <small class="fs-11">{{n}}</small>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    export default {
        data(){
            return {
                list: [],
                pagination: {
                    last_page: 1
                }
            }
        },
        created(){
            this.fetchList();
        },
        methods: {
            fetchList(Page = 1){
                this.submit(route('api.transaction.list') + '?page='+ Page +'&filters=' + JSON.stringify({status: 2, type: 1, owner_type: 'App\\Models\\Booking', per_page: 50, order_by: {
                        column: 'created_at',
                        DESC: true
                    }}), 'get', 'urgentListSection', false, true)
            },
            successHandler(response){
                this.list = response.payload.data;
                this.pagination = response.payload.meta;
            }
        }
    }
</script>