import { create } from 'zustand'
import { createJSONStorage, persist } from 'zustand/middleware'

import type { SidebarStore } from './sidebar.type'

export const sidebarStore = create(
	persist<SidebarStore>(
		set => ({
			isOpen: false,
			setIsOpen: (value: boolean) => set({ isOpen: value })
		}),
		{
			name: 'sidebar',
			storage: createJSONStorage(() => localStorage)
		}
	)
)
