import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

declare module 'vue-router' {
  interface RouteMeta {
    layout?: 'Blank' | 'Default'
  }
}

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '',
      redirect: '/projects',
    },
    {
      path: '/projects',
      component: HomeView,
      children: [
        { path: '', component: () => import('@/views/ProjectRootView.vue') },
        {
          path: ':key/issues',
          name: 'issues',
          component: () => import('@/views/IssuesRootView.vue'),
          props: (route) => ({ selectedIssue: route.query.selectedIssue }),
        },
      ],
    },
  ],
})

router.beforeResolve((to, from) => {})

export default router
