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"),
        meta: {
          title: "Login",
        },
      },
    ],
  },
  {
    path: "/location",
    component: () => import("layouts/LoginLayout.vue"),
    children: [
      {
        path: "map",
        name: "LocationMapPage",
        component: () => import("pages/location/LocationMapPage.vue"),
        meta: { title: "Confirmar localização" },
      },
      {
        path: "address",
        name: "AddressCompletionPage",
        component: () => import("pages/location/AddressCompletionPage.vue"),
        meta: { title: "Confirmar endereço" },
      },
    ],
  },

  // Always leave this as last one,
  // but you can also remove it
  {
    path: "/:catchAll(.*)*",
    component: () => import("pages/ErrorNotFound.vue"),
  },
];

export default routes;
