import { onMounted, onUnmounted } from 'vue'
import { useUIStore } from '../../stores/ui'

export function usePageTitle(title) {
  const uiStore = useUIStore()

  onMounted(() => {
    if (title) {
      uiStore.setPageTitle(title)
    }
  })

  return {
    setTitle: (newTitle) => uiStore.setPageTitle(newTitle),
    resetTitle: () => uiStore.resetPageTitle()
  }
}
