import { useRoute, useRouter } from 'vue-router'
import _without from 'lodash/without'
import { computed } from 'vue'

export default () => {
    const route = useRoute()
    const router = useRouter()

    const menuOpen = computed(() => route.query?.menuOpen === 'true')

    const closeMenu = () => {
        router.push({
            query: _without(route.query, 'menuOpen'),
        })
    }
    const openMenu = () => {
        router.push({
            query: {
                menuOpen: true,
            },
        })
    }

    return {
        menuOpen,
        closeMenu,
        openMenu,
    }
}
