import { defineStore } from 'pinia'
import { ref, reactive } from 'vue'
import { usePiyangoStore } from './piyangoStore'
import { useUsersStore } from '@/stores/usersStore'

export const usePiyangoOnayStore = defineStore('piyangoOnayStore', () => {
  const piyangoStore = usePiyangoStore()
  const usersStore = useUsersStore()

  const piyangoOnayBaseForm = reactive<Record<string, any>>({
    onayDurumuIslemTipiId: null,
    onayCekilisId: piyangoStore.selectedLottery,
    kisiId: usersStore.userId,
    aciklama: '',
    file: '',
    izinSayisi: '',
    izinTarihi: '',
    izinAciklamasi: '',
    kapsamDisiSebebi: null,
    mudurlukId: null,
    cekilisGorevlisiId: null
  })
  const piyangoOnayForm = reactive<Record<string, any>>({})
  const piyangoPanelOnayForm = reactive<Record<string, any>>({})
  const piyangoOnaySafeForm = reactive<Record<string, any>>({})
  const isUpdate = ref<boolean>(false)
  const refreshList = ref<boolean>(false)
  const loaded = ref<boolean>(false)
  const onayPanelLoaded = ref<boolean>(false)
  const onayFormPanel = ref<boolean>(false)

  const ResetForm = () => {
    Object.assign(piyangoOnayForm, piyangoOnayBaseForm)
  }

  return {
    piyangoOnayBaseForm,
    piyangoOnayForm,
    piyangoPanelOnayForm,
    piyangoOnaySafeForm,
    isUpdate,
    refreshList,
    loaded,
    onayPanelLoaded,
    onayFormPanel,
    ResetForm
  }
})
