import { defineStore } from 'pinia'
import { ref, reactive } from 'vue'

export const useAppUserUnitStore = defineStore('appUserUnitStore', () => {
  const appUserUnits = ref<Record<string, any>[]>([])
  const appUserUnitBaseForm = reactive<Record<string, any>>({
    birimAdi: '',
    appUsers: []
  })
  const appUserUnitForm = reactive<Record<string, any>>({})
  const appUserUnitSafeForm = reactive<Record<string, any>>({})
  const isUpdate = ref<boolean>(false)
  const refreshList = ref<boolean>(false)
  const unitPanel = ref<boolean>(false)

  const ResetForm = () => {
    Object.assign(appUserUnitForm, appUserUnitBaseForm)
  }

  return {
    appUserUnits,
    appUserUnitBaseForm,
    appUserUnitForm,
    appUserUnitSafeForm,
    isUpdate,
    refreshList,
    unitPanel,
    ResetForm
  }
})
