<template>
    <v-menu
        v-model="menu.visible"
        :position-x="menu.x"
        :position-y="menu.y"
        absolute
        offset-y
        :close-on-content-click="false"
        :close-on-click="false"
    >
        <v-card
            tile
            flat
        >
            <v-card-text class="pa-2"> 
                <v-alert
                    type="error"
                >
                    {{ __('Sunteți sigur că doriți să dezasociați utilizatorul?') }}
                </v-alert>
            </v-card-text>

            <v-card-actions>
                 <cs-btn 
                    caption="Dezasociază"
                    icon="mdi-delete"
                    color="red"
                    outlined
                    tooltip="Confirmă dezaocierea"
                    :loading="app.requests.Dezasociazacurs.processing"
                    :disabled="app.requests.Dezasociazacurs.processing"
                    @click="OnClickSave"
                />

                <v-spacer></v-spacer>
                
                <cs-btn 
                    caption="Renunță"
                    icon="mdi-close"
                    @click="OnClickCancel"
                />
            </v-card-actions>
        </v-card>
    </v-menu>
</template>

<script>
    export default {
        props: {
            app: {required: true},
            menu: {required: true},
            width: {default: 800},
            height: {default: 600},
        },

        methods: {
            OnClickSave() {
                this.app.requests.Dezasociazacurs.ResetData().SetData(this.menu.payload).Request([
                    response => {
                        this.app.dataSession.Cursuri.GetById(this.app.payload.curs_id);
                        this.app.dataSession.Cursuriatasate.request_count = 0;
                        this.app.dataSession.Cursuriatasate.GetByCursId(this.app.payload.curs_id);
                        this.app.dataSession.Customercursuriuser.GetByCursId(this.app.payload.curs_id);
                        this.OnClickCancel();
                    }
                ])
            },

            OnClickCancel() {
                this.menu.visible = false;
                this.menu.payload = null;
            }
        },

        components: {
            CsBtn: require('@CsVueComp/buttons/CsBtn').default,
        },

        name: 'DesasociereUserMenu'
    }
</script>