import { defineStore } from "pinia";

import piniaPersistConfig from "@/config/piniaPersist";

export const useUserStore = defineStore({
    id: "gw-user",
    state: () => ({
        uid: "",
        token: "",
        avatar: "",
        username: "",
        languageType: null
    }),
    getters: {},
    actions: {
        // Set Token
        setToken(token: string) {
            this.token = token;
        },
        setNickname(userName: string) {
            this.username = userName;
        },
        setUid(uid: string) {
            this.uid = uid;
        },
        setAvatar(avatar: string) {
            this.avatar = avatar;
        },
        setLanguageType(type: any) {
            this.languageType = type;
        }
    },
    persist: piniaPersistConfig("gw-user")
});
