import { defineStore } from 'pinia'
import { useDataStore } from '@/stores/dataStore'
import { useUsersStore } from '@/stores/usersStore'
import { useUyeIrtibatKisiStore } from '../stores/uyeIrtibatKisiStore'

export const useUyeIrtibatKisiService = defineStore('uyeIrtibatKisiService', () => {
  const dataStore = useDataStore()
  const usersStore = useUsersStore()
  const uyeIrtibatKisiStore = useUyeIrtibatKisiStore()

  const GetAllIrtibatKisiler = async (id?: number | string) => {
    let userId = id || usersStore.selectedUserId()
    let data: Record<string, any> | any = await dataStore.dataGet(
      'AppUserContactPerson/GetContactPersonAppUserId/' + userId + '?pageNumber=0'
    )

    if (data !== 'errorfalse') {
      uyeIrtibatKisiStore.uyeAllIrtibatKisiList = data.data
    }
  }
  return { GetAllIrtibatKisiler }
})
