<template>
    <customer-dashboard-page 
        v-if="isCustomersBooted && activeCustomer"
        :app="app"
        :customer="activeCustomer"
        :dashboardItems="customerDashboardItems"
    />

    <cs-centered-alert v-else
        :height="app.height"
        :width="app.width"
        message="Se încarcă..."
    >
        <v-progress-circular indeterminate color="orange darken-1" />
    </cs-centered-alert>
</template>

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

        methods: {
            
            LoadResources() {
                this.app.AddClassesByContext(require.context('./../../Classes', true, /\.class.js$/i));
                this.app.AddDataProvidersByContext(require.context('./../../DataSessions', true, /\.dataprovider.js$/i));
                this.app.AddDatatablesByContext(require.context('./../../Datatables', true, /\.datatable.js$/i));
                this.app.AddFormProvidersByContext(require.context('./../../FormProviders', true, /\.formprovider.js$/i));                
                this.app.AddFormsByContext(require.context('./../../Forms', true, /\.form.js$/i));
                this.app.AddFilterFormsByContext(require.context('./../../FilterForms', true, /\.filterform.js$/i));
                this.app.AddMenusByContext(require.context('./../../Toolbars', true, /\.toolbar.js$/i));
                this.app.AddMenusByContext(require.context('./../../Menus', true, /\.menu.js$/i));
                this.app.AddRequestsByContext(require.context('./../../Requests', true, /\.request.js$/i));
            },

            LoadData() {
                this.app.dataSession.Customers.GetById(this.app.payload.customer_id);
                this.app.dataSession.Customersstatuses.Post();
                this.app.dataSession.Dashboarditems.Post();
            }
        },

        created() {
            this.LoadResources(); 
            this.LoadData();
        },

        components: {
            CsCenteredAlert: require('@CsVueComp/sheets/CsCenteredAlert').default,
        },

        name: 'Index',
    }
</script>