/**
 * UI state for the desktop app — sidebar open/closed, active date.
 */
import { defineStore } from "pinia"
import { useLocalStorage } from "@vueuse/core"

export const useUiStore = defineStore("ui", () => {
  const leftSidebarOpen = useLocalStorage("ui.left-sidebar", false)
  const rightSidebarOpen = useLocalStorage("ui.right-sidebar", false)
  const activeDate = ref("")

  /** Set the active journal date. JournalView watches this and scrolls. */
  function setActiveDate(date: string) {
    activeDate.value = date
  }

  return {
    leftSidebarOpen,
    rightSidebarOpen,
    activeDate,
    setActiveDate,
  }
})
