import { defineStore } from 'pinia'
import {ref, type Ref} from 'vue'

export const useUserInfo = defineStore('userInfo', () => {
  const username: Ref<string | null> = ref(null);
  const userId: Ref<number | null> = ref(null);

  function setUserInfo(name: string, id: number) {
    username.value = name;
    userId.value = id;
  }

  function clearUserInfo() {
    username.value = null;
    userId.value = null;
  }

  return { username, userId, setUserInfo, clearUserInfo };
});
