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

export const useCustomerDocumentStore = defineStore('customerDocumentStore', () => {
  const usersStore = useUsersStore()

  const customerDocumentsList = ref<Record<string, any>[]>([])
  const customerDocumentBaseForm = reactive<Record<string, any>>({
    file: null,
    cekilisId: usersStore.selectedUserId(),
    title: ''
  })
  const customerDocumentForm = reactive<Record<string, any>>({})
  const customerDocumentSafeForm = reactive<Record<string, any>>({})
  const isUpdate = ref<boolean>(false)
  const documentPanel = ref<boolean>(false)
  const loaded = ref<boolean>(false)

  const ResetForm = () => {
    Object.assign(customerDocumentForm, customerDocumentBaseForm)
  }

  return {
    customerDocumentsList,
    customerDocumentBaseForm,
    customerDocumentForm,
    customerDocumentSafeForm,
    isUpdate,
    documentPanel,
    loaded,
    ResetForm
  }
})
