import type { UserInfoType } from '@/api/common';

import { readonly, ref } from 'vue';

import { getUserInfo } from '@/api/common';
import { defineStore } from 'pinia';

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

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

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