import { create } from "zustand";

type State = {
  isLoading: boolean;
  user: any;
};

type Actions = {
  setIsLoading: (isLoading: boolean) => void;
  setUser: (user: {}) => void;
};

// define the initial state
const initialState: State = {
  isLoading: false,
  user: {},
};

// create store
const useUser = create<State & Actions>()((set, get) => ({
  ...initialState,

  setIsLoading: (isLoading: boolean) => {
    set({ isLoading });
  },

  setUser: (user: any) => {
    set({ user });
  },
}));

export { useUser };
