import { defineStore } from 'pinia';
import Cookies from 'js-cookie';
import { setAccount, removeAccount } from "@/utils/auth";

export const useUserStore = defineStore("user", {
  state: () => ({
    username: Cookies.get('username') || null,
  }),
  actions: {
    async fetchUserInfo() {
      // Simulate API call
    },
    setUserInfo(params: any) {
      setAccount({
        username: params.username,
        password: params.password,
        rememberMe: params.rememberMe ? "true" : "false",
      });
    },
    clearUserInfo() {
      removeAccount();
    },
  },
});
