<template>
    <div class="form-part form-title" v-if="usersStore.isPanelUser">
      <div class="form-title-buttons">
        <button
          class="button-c button-save"
          @click="piyangoTeminatService.SaveTeminatDurum"
          :disabled="!piyangoTeminatValidationStore.formChanged">
          Kaydet
        </button>
        <button
          v-if="piyangoTeminatValidationStore.formChanged"
          class="button-c button-cancel panel-close"
          @click="piyangoTeminatStore.ResetFormData">
          Vazgeç
        </button>
      </div>
    </div>
    <div :class="['form-part', piyangoTeminatValidationStore.formChanged ? 'changed' : '']"> <div
      class="form-part-content"
      v-if="piyangoTeminatStore.loaded">
      <form-select
        v-if="usersStore.isPanelUser"
        label="İşlem"
        :listData="piyangoDataStore.piyangoTeminatDurumlari"
        listText="value"
        listVal="id"
        v-model="piyangoTeminatStore.piyangoTeminatFormData.state"
        required
        :invalidText="piyangoTeminatValidationStore.invalidTexts.state"
        @change="OnKeyup" />

      <form-display
        v-model="piyangoTeminatStore.piyangoTeminatFormData.amount"
        half
        label="Tutarı" />

      <form-display
        v-model="piyangoTeminatStore.piyangoTeminatFormData.teminatParentTypeText"
        half
        label="Para Birimi" />

      <form-display
        label="Teminat Türü"
        half
        v-model="piyangoTeminatStore.piyangoTeminatFormData.teminantChildTypeText" />

      <form-display
        type="date"
        half
        v-model="piyangoTeminatStore.piyangoTeminatFormData.teminantDate"
        label="Tarih" />

      <form-display
        v-model="piyangoTeminatStore.piyangoTeminatFormData.teminantNo"
        half
        label="No" />
      <div class="form-item form-item-half"></div>

      <form-display
        v-model="piyangoTeminatStore.piyangoTeminatFormData.bankName"
        half
        label="Banka Adı" />

      <form-display
        v-model="piyangoTeminatStore.piyangoTeminatFormData.bankBranch"
        half
        label="Banka Şubesi" />

      <!--form-display
        label="İşlem"
        v-model="piyangoTeminatStore.piyangoTeminatFormData.stateText" /-->

      <file-list-item
        title="Dosya"
        :data="piyangoTeminatStore.piyangoTeminatFormData"
        :editable="false"
        :filePath="piyangoTeminatStore.piyangoTeminatFormData.teminantDocumentUrl"
        :usePath="true"
        :onlyPreview="true" />

      <form-display
        v-model="piyangoTeminatStore.piyangoTeminatFormData.description"
        label="Açıklama" />
    </div></div>
   
</template>
<script setup lang="ts">
  import { usePiyangoTeminatStore } from '../../stores/piyangoTeminatStore'
  const piyangoTeminatStore = usePiyangoTeminatStore()
  import { useUsersStore } from '@/stores/usersStore'
  const usersStore = useUsersStore()
  import { usePiyangoDataStore } from '../../stores/piyangoDataStore'
  const piyangoDataStore = usePiyangoDataStore()
  import { usePiyangoTeminatValidationStore } from '../../validation/piyangoTeminatValidationStore'
  const piyangoTeminatValidationStore = usePiyangoTeminatValidationStore()
  import { usePiyangoTeminatService } from '../../service/piyangoTeminatService'
  const piyangoTeminatService = usePiyangoTeminatService()

  const OnKeyup = () => {
    piyangoTeminatValidationStore.formChanged = true
  }
</script>
