import { create } from "zustand";
import { devtools } from "zustand/middleware";

interface SidebarState {
  isOpen: boolean;
  setIsOpen: (value: boolean) => void;
  currentTab: number;
  setCurrentTab: (tab: number) => void;
  selectedDay: Date | null;
  setSelectedDay: (day: Date) => void;
  selectedTime: string | null;
  setSelectedTime: (time: string) => void;
  name: string;
  setName: (name: string) => void;
  phone: string;
  setPhone: (phone: string) => void;
  email: string;
  setEmail: (email: string) => void;
  companyId: string;
  setCompanyId: (buildId: string) => void;
  buildId: string;
  setBuildId: (buildId: string) => void;
  url: string;
  setUrl: (url: string) => void;
}

const useSidebarStore = create<SidebarState>()(
  devtools(
    // persist(
    (set) => ({
      isOpen: false,
      setIsOpen: (value) => set({ isOpen: value }),
      currentTab: 1,
      setCurrentTab: (tab) => set({ currentTab: tab }),
      selectedDay: null,
      setSelectedDay: (day) => set({ selectedDay: day }),
      selectedTime: null,
      setSelectedTime: (time) => set({ selectedTime: time }),
      name: "",
      setName: (name) => set(() => ({ name })),
      phone: "",
      setPhone: (phone) => set(() => ({ phone })),
      email: "",
      setEmail: (email) => set(() => ({ email })),
      companyId: "653673cd20af0dadee9003e6",
      setCompanyId: (companyId) => set({ companyId }),
      buildId: "653675f420af0dadee9003ec",
      setBuildId: (buildId) => set({ buildId }),
      url: "",
      setUrl: (url) => set({ url }),
    })
    // {
    //   name: "tab-storage",
    // }
    // )
  )
);

export default useSidebarStore;
