<template>
  <div :class="['form-part']" id="display-irtibat">
    <div class="form-part-title">
      <h4>İrtibat Bilgileri</h4>
    </div>
    <div class="form-part-content" v-if="loaded">
      <form-display
        v-model="piyangoContactStore.contactData.adSoyad"
        label="Adı ve Soyadı"
        half />
      <form-display v-model="piyangoContactStore.contactData.unvan" label="Ünvanı" half />
      <form-display
        half
        v-model="piyangoContactStore.contactData.telefonNumarasi"
        label="Telefon Numarası" />
      <form-display
        half
        v-model="piyangoContactStore.contactData.faksNumarasi"
        label="Faks Numarası" />
      <form-display
        half
        v-model="piyangoContactStore.contactData.eposta"
        label="E-posta adresi" />
    </div>
  </div>
</template>
<script setup lang="ts">
  import { ref, onBeforeMount } from 'vue'
  import { useDataStore } from '@/stores/dataStore'
  const dataStore = useDataStore()
  import { usePiyangoStore } from '../../stores/piyangoStore'
  const piyangoStore = usePiyangoStore()
  import { usePiyangoContactStore } from '../../stores/piyangoContactStore'
  const piyangoContactStore = usePiyangoContactStore()

  const loaded = ref<boolean>(false)

  const GetData = async () => {
    loaded.value = false
    let dt = await dataStore.dataGet(
      'IrtibatBilgi/GetIrtibatBilgiCekilis/' + piyangoStore.selectedLottery,
      {
        skipErrorForStatuses: [404]
      }
    )

    if (dt !== 'errorfalse' && !dt?._error) {
      Object.assign(piyangoContactStore.contactData, dt)
    }
    setTimeout(()=>{
      loaded.value = true
    },30)
  }
  onBeforeMount(async () => {
    await GetData()
  })
</script>
