<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-fit.gap-11px.items-center
        span.font-bold.text-base {{title}}
        q-icon.edit-button.text-lg.cursor-pointer(name="app:edit" v-if="!isEdit" @click="openEdit" size="20")
      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: {
    title: String,
    cancel: {
      type: Function,
      default: () => {},
    },
    save: {
      type: Function,
      default: () => {},
    },
    openEdit: {
      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)
.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>
