import zitadelAuth from '@/services/zitadelAuth'
import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('@/views/HomeView.vue')
    },
    {
      path: '/blessing-power',
      name: 'blessing-power',
      component: () => import('@/views/BlessingPowerView.vue')
    },
    {
      path: '/fellow-power',
      name: 'fellow-power',
      component: () => import('@/views/FellowPowerView.vue')
    },
    {
      path: '/intimacy-power',
      name: 'intimacy-power',
      component: () => import('@/views/IntimacyPowerView.vue')
    },
    {
      path: '/test',
      name: 'test',
      component: () => import('@/views/TestView.vue')
    },

    {
      path: '/login',
      name: 'login',
      meta: {
        authName: zitadelAuth.oidcAuth.authName
      },
      component: () => import('@/views/Login.vue')
    },
    {
      path: '/admin',
      name: 'admin',
      meta: {
        authName: zitadelAuth.oidcAuth.authName
      },
      component: () =>
        zitadelAuth.hasRole('admin') ? import('@/views/Admin.vue') : import('@/views/NoAccess.vue')
    }
  ]
})

zitadelAuth.oidcAuth.useRouter(router)

export default router
