import { defineStore } from "pinia";
export const useUserStore = defineStore("user", {
  state: () => ({
    userInfo: null,
    authToken: "",
  }),
  actions: {
    setUseInfo(data) {
      this.userInfo = data;
      this.authToken = data.token;

      sessionStorage.setItem("authToken", data.token);
      sessionStorage.setItem("userInfo", JSON.stringify(data));
    },
    clearUserInfo() {
      this.userInfo = null;
      this.authToken = "";
      sessionStorage.removeItem("authToken");
      sessionStorage.removeItem("userInfo");
    },
  },
});
