import { _ as __nuxt_component_0 } from "./nuxt-link-C5PnX__I.js"; import { defineComponent, ref, watch, computed, withCtx, createTextVNode, toDisplayString, useSSRContext } from "vue"; import { ssrRenderAttrs, ssrInterpolate, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrRenderClass, ssrRenderComponent } from "vue/server-renderer"; import "/app/node_modules/hookable/dist/index.mjs"; import { c as useCookie } from "../server.mjs"; import "/app/node_modules/ufo/dist/index.mjs"; import "/app/node_modules/defu/dist/defu.mjs"; import "/app/node_modules/ofetch/dist/node.mjs"; import "#internal/nuxt/paths"; import "/app/node_modules/unctx/dist/index.mjs"; import "/app/node_modules/h3/dist/index.mjs"; import "pinia"; import "vue-router"; import "/app/node_modules/klona/dist/index.mjs"; import "/app/node_modules/cookie-es/dist/index.mjs"; import "/app/node_modules/destr/dist/index.mjs"; import "/app/node_modules/ohash/dist/index.mjs"; import "/app/node_modules/@unhead/vue/dist/index.mjs"; import "@vue/devtools-api"; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "index", __ssrInlineRender: true, setup(__props) { const loading = ref(true); const error = ref(null); const garages = ref([]); const availableTiers = ref([]); const searchQuery = ref(""); const filterType = ref("all"); const selectedPackage = ref("all"); const availableTierNames = ref([]); const showSubscriptionModal = ref(false); const selectedGarage = ref(null); const selectedTierId = ref(""); const customExpiresAt = ref(""); const saving = ref(false); const saveError = ref(null); const saveNotification = ref(null); let searchDebounceTimer = null; function debouncedFetchGarages() { if (searchDebounceTimer) { clearTimeout(searchDebounceTimer); } searchDebounceTimer = setTimeout(() => { fetchGarages(); }, 400); } watch(searchQuery, () => { debouncedFetchGarages(); }); watch(filterType, () => { fetchGarages(); }); watch(selectedPackage, () => { fetchGarages(); }); const globalTotalCount = ref(0); const globalIndividualCount = ref(0); const globalCorporateCount = ref(0); const isFilterActive = computed(() => { return searchQuery.value !== "" || filterType.value !== "all" || selectedPackage.value !== "all"; }); watch(garages, (newGarages) => { const currentSet = new Set(availableTierNames.value); for (const g of newGarages) { if (g.subscription_tier_name) { currentSet.add(g.subscription_tier_name); } } availableTierNames.value = Array.from(currentSet).sort(); }, { immediate: true, deep: true }); const filteredGarages = computed(() => garages.value); function getAuthHeaders() { const tokenCookie = useCookie("access_token"); const token = tokenCookie.value; return token ? { Authorization: `Bearer ${token}` } : {}; } async function fetchGarages() { loading.value = true; error.value = null; try { const params = { limit: 200 }; if (searchQuery.value) { params.search_term = searchQuery.value; } if (filterType.value !== "all") { params.org_type_filter = filterType.value; } if (selectedPackage.value !== "all") { params.tier_name_filter = selectedPackage.value; } const response = await $fetch("/api/v1/admin/organizations", { params, headers: getAuthHeaders() }); garages.value = response.garages; if (!isFilterActive.value) { globalTotalCount.value = response.total; globalIndividualCount.value = garages.value.filter((g) => g.org_type === "individual").length; globalCorporateCount.value = garages.value.filter((g) => g.org_type !== "individual").length; } } catch (err) { console.error("[Garages] Failed to fetch garages:", err); error.value = err?.data?.detail || err?.message || "Failed to load garages"; } finally { loading.value = false; } } function garageDisplayName(garage) { return garage.display_name || garage.name || garage.full_name; } function getInitials(name) { return name.split(" ").map((w) => w.charAt(0)).join("").toUpperCase().slice(0, 2); } function getInitialsColor(name) { const colors = [ "bg-amber-600", "bg-purple-600", "bg-slate-600", "bg-indigo-600", "bg-emerald-600", "bg-rose-600", "bg-cyan-600", "bg-orange-600", "bg-teal-600" ]; let hash = 0; for (let i = 0; i < name.length; i++) { hash = name.charCodeAt(i) + ((hash << 5) - hash); } return colors[Math.abs(hash) % colors.length]; } function statusBadgeClass(status) { if (status === "active") return "bg-emerald-500/10 text-emerald-400"; if (status === "suspended") return "bg-red-500/10 text-red-400"; if (status === "pending_verification") return "bg-amber-500/10 text-amber-400"; return "bg-slate-500/10 text-slate-400"; } function statusDotClass(status) { if (status === "active") return "bg-emerald-400"; if (status === "suspended") return "bg-red-400"; if (status === "pending_verification") return "bg-amber-400"; return "bg-slate-400"; } function statusLabel(status) { if (status === "active") return "Aktív"; if (status === "suspended") return "Felfüggesztve"; if (status === "pending_verification") return "Függőben"; return "Inaktív"; } function tierBadgeClass(tierName) { const name = tierName.toLowerCase(); if (name.includes("enterprise") || name.includes("vip") || name.includes("corp")) return "bg-purple-500/20 text-purple-300"; if (name.includes("premium") || name.includes("pro")) return "bg-amber-500/20 text-amber-300"; return "bg-slate-500/20 text-slate-300"; } function formatDate(dateStr) { try { const d = new Date(dateStr); return d.toLocaleDateString("hu-HU", { year: "numeric", month: "short", day: "numeric" }); } catch { return dateStr; } } return (_ctx, _push, _parent, _attrs) => { const _component_NuxtLink = __nuxt_component_0; _push(`
${ssrInterpolate(_ctx.$t("garages.subtitle"))}
${ssrInterpolate(_ctx.$t("garages.loading"))}
${ssrInterpolate(error.value)}
${ssrInterpolate(_ctx.$t("garages.total_garages"))}
${ssrInterpolate(globalTotalCount.value)}
${ssrInterpolate(_ctx.$t("garages.private_garages"))}
${ssrInterpolate(globalIndividualCount.value)}
${ssrInterpolate(_ctx.$t("garages.corporate_garages"))}
${ssrInterpolate(globalCorporateCount.value)}
| ID | ${ssrInterpolate(_ctx.$t("garages.company_name"))} | ${ssrInterpolate(_ctx.$t("garages.status"))} | ${ssrInterpolate(_ctx.$t("garages.current_package"))} | ${ssrInterpolate(_ctx.$t("garages.expiration_date"))} | ${ssrInterpolate(_ctx.$t("garages.actions"))} |
|---|---|---|---|---|---|
| ${ssrInterpolate(garage.id)} | ${ssrInterpolate(getInitials(garageDisplayName(garage)))} `);
_push(ssrRenderComponent(_component_NuxtLink, {
to: "/garages/" + garage.id,
class: "text-sm font-medium text-white hover:underline cursor-pointer hover:text-indigo-400 transition-colors"
}, {
default: withCtx((_, _push2, _parent2, _scopeId) => {
if (_push2) {
_push2(`${ssrInterpolate(garageDisplayName(garage))}`);
} else {
return [
createTextVNode(toDisplayString(garageDisplayName(garage)), 1)
];
}
}),
_: 2
}, _parent));
_push(` ${ssrInterpolate(garage.city || "—")} · ${ssrInterpolate(garage.member_count)} ${ssrInterpolate(_ctx.$t("garages.members"))} | ${ssrInterpolate(statusLabel(garage.status))} | ${ssrInterpolate(garage.subscription_tier_name)} | `); if (garage.subscription_expires_at) { _push(`${ssrInterpolate(formatDate(garage.subscription_expires_at))}`); } else { _push(`${ssrInterpolate(_ctx.$t("garages.indefinite"))}`); } _push(` |
${ssrInterpolate(_ctx.$t("garages.no_results"))}
${ssrInterpolate(selectedGarage.value ? garageDisplayName(selectedGarage.value) : "")}
${ssrInterpolate(_ctx.$t("garages.current_package"))}
${ssrInterpolate(selectedGarage.value?.subscription_tier_name || _ctx.$t("garages.free_fallback"))}
`); if (selectedGarage.value?.subscription_expires_at) { _push(`${ssrInterpolate(_ctx.$t("garages.expires"))}: ${ssrInterpolate(formatDate(selectedGarage.value.subscription_expires_at))}
`); } else { _push(``); } _push(`${ssrInterpolate(_ctx.$t("garages.custom_expiration_hint"))}
${ssrInterpolate(saveError.value)}