import { create } from "zustand";
import { persist } from "zustand/middleware";
import type { User } from "../api/client";

interface UserStore {
  user: User | null;
  setUser: (user: User | null) => void;
}

export const useUserStore = create<UserStore>()(
  persist(
    (set, get) => ({
      user: null,
      setUser: (user: User | null) => set({ user }),
    }),
    {
      name: "user",
    }
  )
);
