import { watch } from 'vue'
import { useRoute } from 'vue-router'
import { useRouteStore } from '@/stores/route'

export const useRouteSync = () => {
  const route = useRoute()
  const routeStore = useRouteStore()

  watch(
    () => route.path,
    (newPath) => {
      routeStore.setCurrentPath(newPath)
    },
    { immediate: true },
  )

  return routeStore
}
