text: import Vue from 'vue';
  import VueRouter from 'vue-router';
  import Home from '../views/Home.vue';
  import store from '@/store';
  
  function isAuthenticated() {
    return store.state.authModule.isAuthenticated;
  }
  
  Vue.use(VueRouter);
  
  const routes = [
    {
      path: '/',
      name: 'home',
      component: Home
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/Login.vue')
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('../views/Register.vue')
    }
  ];
  
  const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
  });
  
  router.beforeEach((to, from, next) => {
    if (to.name === 'login' && isAuthenticated() || to.name === 'register' && isAuthenticated()) {
      next({ name: 'home' });
    } else {
      next();
    }
  });
  
  export default router;
  