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

export const usePiyangoDocumentStore = defineStore('piyangoDocumentStore', () => {
  const piyangoStore = usePiyangoStore()

  const piyangoDocumentsList = ref<Record<string, any>[]>([])
  const piyangoDocumentBaseForm = reactive<Record<string, any>>({
    dosya: null,
    cekilisId: piyangoStore.selectedLottery,
    dokumanAdi: ''
  })
  const piyangoDocumentForm = reactive<Record<string, any>>({})
  const piyangoDocumentSafeForm = reactive<Record<string, any>>({})
  const isUpdate = ref<boolean>(false)
  const refreshList = ref<boolean>(false)
  const documentPanel = ref<boolean>(false)
  const loaded = ref<boolean>(false)

  const ResetForm = () =>{
    Object.assign(piyangoDocumentForm, piyangoDocumentBaseForm)
  }
  
  return {
    piyangoDocumentsList,
    piyangoDocumentBaseForm,
    piyangoDocumentForm,
    piyangoDocumentSafeForm,
    isUpdate,
    refreshList,
    documentPanel,
    loaded,
    ResetForm
  }
})
