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

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

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

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

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

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

        name: 'DashboardRecordSummaryChestionare',
    }
</script>