<template lang="pug">
  .form-wrapper.relative.h-fit.rounded.w-full
    transition(name="medical-form", mode="out-in")
      .loader.absolute.z-10.flex.items-center.justify-center.w-full.h-full.rounded(v-if="isLoadingData")
        base-loader
    .flex.flex-col.h-full.gap-25px.p-6
      .flex.w-full.justify-between
        .flex.w-fit.gap-11px.items-center(v-if="!tag")
          span.font-bold.text-base.whitespace-nowrap {{title}}
          q-icon.edit-button.text-lg.cursor-pointer(name="app:edit" v-if="!isEdit" @click="openEdit" size="20")
        .flex.w-full.gap-11px.items-center.justify-between(v-else)
          span.font-bold.text-base.whitespace-nowrap {{title}}
          .flex.items-center.h-5(:style="{color: 'var(--btn-blue-color)'}")
            q-btn(flat, no-caps)
              q-icon(left, name="app:plus", size="10px")
              span.text-smm.font-medium Создать шаблон
        .flex.w-fit.gap-10px.items-center.delete-button.cursor-pointer(v-if="!isEdit && titleDelete" @click="deleteItem")
          q-icon(name="app:basket" size="20")
          span.text-smm.font-medium {{ titleDelete }}
      slot
      .flex.h-fit.w-fit.gap-2(v-if="isEdit")
        base-button.text-base.font-semibold(outlined :size="40" @click="cancel") Отменить
        base-button.text-base.font-semibold(v-if="isCheckChange" :size="40" @click="save") Сохранить изменения
</template>

<script>
import BaseButton from "@/components/base/BaseButton.vue";
import BaseLoader from "@/components/Loader/BaseLoader.vue";
export default {
  name: "MedicalFormWrapper",
  components: { BaseButton, BaseLoader },
  props: {
    tag: {
      type: Boolean,
      default: false,
    },
    title: String,
    titleDelete: String,
    cancel: {
      type: Function,
      default: () => {},
    },
    save: {
      type: Function,
      default: () => {},
    },
    openEdit: {
      type: Function,
      default: () => {},
    },
    deleteItem: {
      type: Function,
      default: () => {},
    },
    isCheckChange: {
      type: Boolean,
      default: false,
    },
    isLoadingData: {
      type: Boolean,
      default: false,
    },
    isEdit: {
      type: Boolean,
      default: false,
    },
  },
};
</script>

<style lang="sass" scoped>
.form-wrapper
  background-color: var(--default-white)
.edit-button
  color: var(--btn-blue-color)
  &:hover
    color: var(--btn-blue-color-hover)
.delete-button
  color: var(--font-grey-color)
  &:hover
    opacity: 0.7
.loader
  background-color: var(--default-white)
.medical-form-enter-from
  opacity: 0
  transform: translateY(0px)
  pointer-events: none
.medical-form-leave-to
  opacity: 0
  transform: translateY(0px)
  pointer-events: none
.medical-form-leave-active
  transition: 0.3s ease
.medical-form-move
  transition: 0.3s ease
</style>
