import { createApp } from "vue";
import { createRouter, createWebHistory } from "vue-router";
import App from "./App.vue";
import "./styles.css";

const RoutePlaceholder = { template: "<span />" };

const routes = [
  "/admin/login",
  "/admin/dashboard",
  "/admin/feedbacks",
  "/admin/releases",
  "/admin/legacy/update-info",
  "/admin/legacy/media-types",
  "/admin/sources",
  "/admin/endpoints",
  "/admin/system",
].map((path) => ({ path, component: RoutePlaceholder }));

const router = createRouter({
  history: createWebHistory(),
  routes: [
    ...routes,
    { path: "/admin/database", redirect: { path: "/admin/system", query: { tab: "database" } } },
    { path: "/admin/health", redirect: { path: "/admin/system", query: { tab: "health" } } },
    { path: "/admin/settings", redirect: { path: "/admin/system", query: { tab: "security" } } },
    { path: "/admin/audit", redirect: { path: "/admin/system", query: { tab: "audit" } } },
    { path: "/admin", redirect: "/admin/dashboard" },
    { path: "/admin/:pathMatch(.*)*", redirect: "/admin/dashboard" },
  ],
});

createApp(App).use(router).mount("#app");
