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

export const useMuhasebeSettingsStore = defineStore('muhasebeSettingsStore', () => {
  const usersStore = useUsersStore()

  const muhasebeSettingsBaseForm = reactive<Record<string, any>>({
    appUserId: usersStore.userId,
    basvuruBedeli: '10.167,00',
    BasvuruBedeliKdvOrani: 20,
    kurumBanka: 'Türkiye Vakıflar Bankası T.A.O.',
    kurumBankaSube: 'Ankara Kurumsal',
    kurumIBAN: 'TR26 0001 5001 5800 7295 4624 00'
  })
  const muhasebeSettingsForm = reactive<Record<string, any>>({})
  const muhasebeSettingsSafeForm = reactive<Record<string, any>>({})
  const isNew = ref<boolean>(false)
  const muhasebeSettingsLoaded = ref<boolean>(false)

  const ResetForm = () => {
    Object.assign(muhasebeSettingsForm, muhasebeSettingsBaseForm)
  }
  const SafeServerData = () => {
    Object.assign(muhasebeSettingsSafeForm, muhasebeSettingsForm)
  }

  const RestoreData = () => {
    Object.assign(muhasebeSettingsForm, muhasebeSettingsSafeForm)
  }

  return {
    muhasebeSettingsBaseForm,
    muhasebeSettingsForm,
    muhasebeSettingsSafeForm,
    isNew,
    muhasebeSettingsLoaded,
    ResetForm,
    SafeServerData,
    RestoreData
  }
})
