import { defineStore } from 'pinia'
import { ref, reactive } from 'vue'
import { usePiyangoStore } from './piyangoStore'

export const usePiyangoMecraStore = defineStore('piyangoMecraStore', () => {
  const piyangoStore = usePiyangoStore()

  const piyangoAllMecraData = ref<Record<string, any>[]>([])

  const piyangoMecraBaseForm = reactive<Record<string, any>>({
    cekilisId: piyangoStore.selectedLottery,
    mecraAdi: '',
    yayinlanmaDurumu: 0,
    yayinlanacagiTarih: piyangoStore.baseLotteryData.ilantarihi || new Date()
  })
  const piyangoMecraForm = reactive<Record<string, any>>({})
  const piyangoMecraSafeForm = reactive<Record<string, any>>({})
  const isUpdate = ref<boolean>(false)
  const refreshList = ref<boolean>(false)
  const mecraPanel = ref<boolean>(false)
  const loaded = ref<boolean>(false)

  const ResetForm = () => {
    Object.assign(piyangoMecraForm, piyangoMecraBaseForm)
  }

  return {
    piyangoAllMecraData,
    piyangoMecraBaseForm,
    piyangoMecraForm,
    piyangoMecraSafeForm,
    isUpdate,
    refreshList,
    mecraPanel,
    loaded,
    ResetForm
  }
})
