<template>
  <div class="container">
    <div class="row">
      <div class="col-md-12" style="margin-bottom: 1em">
        <h1>Category</h1>
      </div>
    </div>
    <div class="row" style="text-align:left">
      <div class="col-md-12" style="margin-bottom: 1em">
        <label>Description</label>
        <div class="input-group-prepend">
          <span class="input-group-text">
            <eva-icon name="credit-card-outline" fill="#24aae1"></eva-icon>
          </span>
          <input class="form-control" type="text" name="description" v-model="category.description" />
        </div>
      </div>
    </div>
    <div class="row"></div>
    <div class="row">
      <div class="col-md-12" style="margin-bottom: 1em">
        <div class="input-group-prepend">
          <b-button class="btn btn-b-n" @click="Ok">Ok</b-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Category",
  props: {
    editCategory: { default: {} }
  },
  data() {
    return {
      category: {
        id: 0,
        description: ""
      }
    };
  },
  methods: {
    Ok() {
      this.$emit("CategoryUpdate", this.category);
    }
  },
  watch: {
    editCategory: {
      immediate: true,
      handler(val, oldVal) {
        if (val) {
          this.category = val;
        }
      }
    }
  }
};
</script>