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

export const useUserStore = defineStore('user', () => {
  const id = ref('')
  const displayName = ref('')
  const role = ref('')
  const locale = ref('zh-CN')

  const isLoggedIn = computed(() => Boolean(id.value))

  function loadDemoUser() {
    id.value = 'demo-user'
    displayName.value = 'Arctic Demo User'
    role.value = 'Viewer'
  }

  return {
    id,
    displayName,
    role,
    locale,
    isLoggedIn,
    loadDemoUser,
  }
})
