<template>
    <v-card tile flat class="mb-2" v-if="activeRecord">   
        <v-card-title class="py-2">
            <span class="text-body-1">
                {{ 
                    __('Utilizator :user. Client: :customer', {
                        user: activeRecord.full_name,
                        customer: activeRecord.customer,
                    })
                }}
            </span>
        </v-card-title>
        
        <v-card-text>
            <v-row dense>
                <v-col cols="12">
                    <v-autocomplete
                        dense
                        hide-details
                        class="mt-2"
                        :items="roles"
                        outlined
                        :label="__('Rolul')"
                        v-model="activeRecord.role_id"
                    >
                    </v-autocomplete>
                </v-col>

                <v-col cols="12">
                    <div v-if="! activeRecord.activated">
                        <div class="red--text">
                            {{ __('Contul este neactivat.') }}
                        </div>

                        <v-checkbox
                            dense
                            hide-details
                            :label="__('Activează contul pentru :name', {name: activeRecord.customer})"
                            :true-value="1"
                            :false-value="0"
                            v-model="activeRecord.checked"
                        >
                        </v-checkbox>
                    
                    </div>

                    <div v-else>
                        <div class="red--text">
                            {{ __('Contul este activat la data de :d.', {d: ToDateTime(activeRecord.activated_at)}) }}
                        </div>

                        <v-checkbox
                            dense
                            hide-details
                            :label="__('Deactivează contul pentru :name', {name: activeRecord.customer})"
                            :true-value="1"
                            :false-value="0"
                            v-model="activeRecord.checked"
                        >
                        </v-checkbox>
                    
                    </div>
                </v-col>

            </v-row>
        </v-card-text>
    </v-card>
</template>

<script>
    export default {

        props: {
            editable: {required: true},
        },

        computed: {
            form() {
                return this.editable.form;
            },

            roles() {
                return this.editable.column.datatable.app.dataSession.Roles.selectorItems;
            }
        },

        mounted() {
            setTimeout( () => {
                if( ! this.activeRecord.role_id )
                {
                    this.activeRecord.role_id = 5;
                }
            }, 100);
        },

        mixins: [
            require('@CsVueMix/Forminput/Forminput')
        ],

        name: 'AccountRoleInput',
    }
</script>