import { readonly, ref } from 'vue';
import { defineStore } from 'pinia';
import { getUserInfo } from '@/api/common';
import type { UserInfoType } from '@/api/common';

export const useUserInfoStore = defineStore('userInfoStore', () => {
  const userInfo = ref<UserInfoType>();

  const fetchUserInfo = () => {
    getUserInfo().then((res) => {
      userInfo.value = res.data;
    });
  };

  return { userInfo: readonly(userInfo), fetchUserInfo };
});
