<template>
  <div class="position-relative">
    <form>
      <div class="form-row text__14">
        <label for="">مساله </label>
        <span>{{ data.entity.title }}</span>
      </div>
      <div class="form-row">
        <label for="">پاسخ تفصیلی </label>
        <textarea
          name=""
          id=""
          v-model="value"
          cols="30"
          rows="30"
          placeholder="متن پاسخ تفصیلی"
        ></textarea>
      </div>

      <div class="popUp-tab__buttons">
        <div class="d-flex justify-content-between flex-grow-1">
          <span>&nbsp;</span>

          <div class="d-flex">
            <button
              title="لغو"
              @click.prevent="$emit('close-modal')"
              class="popUp-tab__clear btn"
              type="button"
            >
              لغو
            </button>
            <button
              type="button"
              class="popUp-tab__submit btn"
              @click.prevent="saveProperty()"
            >
              ثبت
            </button>
          </div>
        </div>
      </div>
    </form>
  </div>
</template>

<script>
import { propertyMixin } from "~/chat/mixins/propertyMixin";

export default {
  mixins: [propertyMixin],

  props: {
    data: { type: Object, default: () => ({}) },
  },
  mounted() {
    // this.value = ('description' in this.data.entity ) ?  this.data.entity['description'] : '';
    this.value = this.getPropertyValue(
      this.data.entity,
      this.data.keyName,
      this.data.index
    );
  },
  data() {
    return {
      value: "",
    };
  },
  computed: {
    // propertyObj(){
    //   if(this.data.property){
    //     return this.data.property;
    //   } else {
    //     return this.property;
    //   }
    // }
  },

  methods: {
    // ...mapActions("jahat", ["SAVE_DETAILED_ANSWER"]),
    // saveProperty(){
    //   let self = this;
    //   let property = this.propertyObj;
    //   let index = 0;
    //   property.entity_id = this.data.answerId;
    //   this.SAVE_DETAILED_ANSWER(property).then(response => {
    //     self.$emit('change', {item: response.data, type: 'detailed_answers', index: index});
    //     self.closeModal();
    //   });
    // },
    // closeModal(){
    //   this.propertyObj.value_json = {text: ''};
    //   this.$refs.closeDetailedAnswerModal.click();
    // }
  },
};
</script>
