<template>
    <v-sheet
        width="100%"
        color="transparent"
    >
        
    </v-sheet>
</template>

<script>
    export default {

        props: {
            app: {required: true},
            customer: {required: true},
        },

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

            countFiles() {
                if( ! this.summary )
                {
                    return 0;
                }
                
                return _.sumBy(
                    this.summary.files, 
                    status => (this.app.platform == 'admin' ? 1 : (status.name == 'Public' ? 1 : 0) ) * status.count_files
                )
            }
        },

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

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

        name: 'DashboardRecordSummaryDocuments',
    }
</script>