import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getAuthAPI } from '@/apis/home'

export const useTenantStore = defineStore('tenant', () => {
  const tenantInfo = ref({})

  const getTenantInfo = async () => {
    const res = await getAuthAPI()
    if (res.data.voList.length > 0) {
      tenantInfo.value = res.data.voList[0]
    }
  }

  const clearTenantInfo = () => {
    tenantInfo.value = {}
  }

  return {
    tenantInfo,
    getTenantInfo,
    clearTenantInfo
  }
}, {
  persist: true
})