<template>
  <div class="field">
    <div class="control">
      <textarea
        v-model="record.note"
        class="textarea"
        name="note"
        placeholder=""
        rows="8"
      ></textarea>
    </div>
  </div>
  <div class="mt-4">
    <button
      class="button is-primary has-text-white"
      @click="save()"
    >
      {{ $store.lang === "vi" ? "Lưu lại" : "Save" }}
    </button>
  </div>
</template>
<script setup>
const emit = defineEmits(["close"]);
const { $getdata, $patchapi, $updatepage } = useNuxtApp();
const props = defineProps({
  row: Object,
  pagename: String,
});
let record = await $getdata("application", {
  filter: { id: props.row.id },
  first: true,
});
async function save() {
  await $patchapi("application", record);
  record = await $getdata("application", {
    filter: { id: props.row.id },
    first: true,
  });
  $updatepage(props.pagename, record);
  emit("close");
}
</script>
