<template>
    <v-sheet
        width="100%"
        color="transparent"
    >
        <customer-cursuri-summary 
            v-if="summary"
            :countCursuri="summary.count"
        />
    </v-sheet>
</template>

<script>
    export default {
        props: {
            app: {required: true},
            customer: {required: true},
        },

        computed: {
            summary() {
                if(this.app.requests.GetCursuriSummary.processing)
                {
                    return null;
                }
                return this.app.requests.GetCursuriSummary.response.payload;
            },
        },

        methods: {
            GetSummary() {
                this.app.requests.GetCursuriSummary
                    .ResetData()
                    .SetData({
                        customer_id: this.customer.id,
                    })
                    .Request([
                        response => {
                            this.$emit('disabled', (this.summary.count == 0));
                        }
                    ])
            }
        },

        created() {
            this.GetSummary();
        },

        components: {
            CustomerCursuriSummary: require('./CustomerCursuriSummary').default,
        },

        name: 'DashboardRecordSummaryCursuri',
    }
</script>