import { createRouter, createWebHistory } from 'vue-router'

function lazyLoad(view) {
  return () => import(`@/views/${view}.vue`)
}

const routes = [
  {
    path: '/',
    name: 'Home',
    component: lazyLoad('Home')
  },
  {
    path: '/player/:id',
    name: 'Player',
    component: lazyLoad('Player'),
    props: true
  },
  {
    path: '/player/:id/matches',
    name: 'MyMatches',
    component: lazyLoad('MyMatches'),
    props: true
  },
  {
    path: '/match/:match_id',
    name: 'Match',
    component: lazyLoad('Match'),
    props: true
  },
  {
    path: '/explore',
    name: 'Explore',
    component: lazyLoad('Explore'),
    props: true
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/'
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
