<template>
    <div class="dropdown is-right navbar-item" :class="{'is-active':activa}">
        <div class="dropdown-trigger">
            <a class="text-a" aria-haspopup="true" :aria-controls="id" @click.capture="toggle">
            <span class="icon is-small mr-1">
                <img src="/assets/chismosa.png">
            </span>
            <span v-text="'$' + total"></span>
            </a>
        </div>
    </div>
</template>

<script>
import Chismosa from './Chismosa.vue'
export default {
    components: {
        Chismosa
    },
    props: {
        id: {
            type: String,
            required: true
        }
    },
    data() {
        return {
            activa: false,
            total: 0,
        }
    },
    mounted() {
        Event.$on('pedido-actualizado', this.actualizar);
    },
    methods: {
        toggle() {
            this.activa = !this.activa;
            Event.$emit("toggle-chismosa", this.activa);
        },
        actualizar() {
            this.total = this.$limpiarInt(this.$root.devoluciones ? this.$root.pedido.total_menos_devoluciones : this.$root.pedido.total);
        },
    },
}
</script>
