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

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

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

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

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

        components: {
            CustomerCentralizatoareSummary: require('@MyDpoComp/Entities/CustomerCentralizatoare/Summary/CustomerCentralizatoareSummary').default,
        },

        name: 'DashboardRecordSummaryCentralizatoare',
    }
</script>