<template>
  <div class="fixed-plugin" v-click-outside="closeDropDown">
    <div class="dropdown show-dropdown" :class="{ show: isOpen }">
      <a data-toggle="dropdown" class="settings-icon">
        <i class="fa fa-plus fa-2x" @click="toggleDropDown"> </i>
      </a>
      <span class="dropdown-menu" :class="{ show: isOpen }">
        <card>
          <template slot="header">
            <img v-if="isUpdate === false" src="img//card-primary.png" alt="" />
            <img v-else src="img//card-info.png" alt="" />
          </template>
          <base-input
            label="Fecha"
            v-model="newIngreso.fecha"
            type="Date"
            required
          ></base-input>
          <base-input
            label="Descripcion"
            v-model="newIngreso.detalle"
          ></base-input>
          <base-input
            label="Valor"
            type="Number"
            v-model="newIngreso.valor"
          ></base-input>
          <base-button
            v-if="isUpdate === false"
            type="primary"
            class="mb-3 col-12"
            size="lg"
            @click="saveIngreso()"
            >Guardar</base-button
          >

          <base-button
            v-else
            type="info"
            class="mb-3 col-12"
            size="lg"
            @click="updateIngreso(newIngreso._id)"
            >Actualizar</base-button
          >
        </card>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: "Fingreso",
  props: ["newIngreso", "saveIngreso", "isUpdate", "updateIngreso", "openForm"],
  data() {
    return {
      isOpen: this.openForm,
    };
  },
  methods: {
    toggleDropDown() {
      this.isOpen = !this.isOpen;
    },
    closeDropDown() {
      this.isOpen = false;
    },
  },
};
</script>

<style scoped lang="scss">
.settings-icon {
  cursor: pointer;
}

.badge-vue {
  background-color: #ffffff;
}

.color_fondo {
  background-color: #ffffff;
}
</style>