import { comparePaths } from '@utils/scopes';
import { lazyLoadView } from '@utils/lazyloadview';

const categories = {
  cards: {
    path: 'cards',
  },
};

const routes = [
  {
    children: [
      {
        component: () => import('@components/common/base-card/index.vue'),
        name: 'cards',
        path: ':path/:id',
        meta: {
          hasRedirectToStepper: true,
        },
      },
    ],
    component: () => lazyLoadView(import('@router/cards/index.vue')),
    path: categories.cards.path,
    beforeEnter: (to, from, next) => {
      if (to.name === 'cards' && !comparePaths(to.params.path)) {
        next('');
      } else {
        next();
      }
    },
  },
];

export default routes;
