let sub_routes = [];

const modules = import.meta.glob("./routes/*.route.js", { eager: true });
// eslint-disable-next-line no-unused-vars
Object.entries(modules).forEach(([path, definition]) => {
  sub_routes = sub_routes.concat(definition.default);
});

const routes = [
  {
    path: "/",
    component: () => import("layouts/MainLayout.vue"),
    meta: { requireAuth: true },
    children: [
      {
        path: "",
        name: "DashboardPage",
        component: () => import("src/pages/dashboard/DashboardPage.vue"),
        meta: {
          title: "ui.navigation.dashboard",
          requireAuth: true,
          requiredPermission: "dashboard",
          breadcrumbs: [
            {
              name: "DashboardPage",
              title: "ui.navigation.dashboard",
            },
          ],
        },
      },

      ...sub_routes,
    ],
  },

  {
    path: "/login",
    component: () => import("layouts/LoginLayout.vue"),
    children: [
      {
        path: "",
        name: "LoginPage",
        component: () => import("pages/LoginPage.vue"),
      },
    ],
  },

  {
    path: "/:catchAll(.*)*",
    component: () => import("pages/ErrorNotFound.vue"),
  },
];

export default routes;