<template>
  <list-table-content
    v-if="loaded"
    :tableHeader="tableHeader"
    formTitle="Piyango Onay Logları"
    listText="Kayıt"
    :apiList="'OnayDurumLog/Cekilis/' + piyangoStore.selectedLottery"
    apiText="Piyango Onay Log Listesi"
    page="form"
    :refresh="piyangoOnayStore.refreshList" />
</template>
<script setup lang="ts">
  import { ref, onBeforeMount, computed } from 'vue'
  import { useDateStore } from '@/stores/dateStore'
  const dateStore = useDateStore()
  import { usePiyangoOnayStore } from '../../stores/piyangoOnayStore'
  const piyangoOnayStore = usePiyangoOnayStore()
  import { usePiyangoStore } from '../../stores/piyangoStore'
  const piyangoStore = usePiyangoStore()

  const loaded = ref<boolean>(false)

  const tableHeader = ref<Record<string, any>[]>([
    {
      name: 'tarih',
      title: 'Tarih',
      compute: (v: Record<string, any>): string => {
        return v.tarih === null
          ? ''
          : dateStore.dateFormat({ pattern: 'dd-mm-yy', date: v.tarih })
      },
      sort: true,
      filter: {
        type: 'date',
        between: true
      }
    },
    {
      name: 'islemYapanKullanici',
      title: 'Kişi',
      sort: true,
      style: { width: '20%' }
    },
    {
      name: 'eskiDurum',
      title: 'Eski Durum'
    },
    {
      name: 'yeniDurum',
      title: 'Yeni Durum'
    },
    {
      name: 'aciklama',
      title: 'Açıklama',
      sort: true,
      style: { width: '30%' }
    }
  ])

  onBeforeMount(async () => {
    loaded.value = true
  })
</script>
