import { Wallet } from "@/api/user";
import { create } from "zustand";

interface State {
    wallet: Wallet;
    score: Wallet["Score"];
}

interface Action {
    setWallet: (state: Wallet) => void;
    setScore: (state: Wallet["Score"]) => void;
    reset: () => void;
}
const initialState: State = {
    wallet: {},
    score: 0,
};
export const useWalletStore = create<State & Action>()((set) => {
    return {
        ...initialState,
        setWallet: (wallet) => {
            set((state) => ({ ...state, wallet }));
        },
        setScore: (score) => {
            set((state) => ({ ...state, score }));
        },
        reset: () => set(initialState),
    };
});
