Files
service-finder/frontend_admin/.nuxt/dist/server/_nuxt/index-7zBAzpaD.js

160 lines
16 KiB
JavaScript

import { defineComponent, ref, computed, useSSRContext } from "vue";
import { ssrRenderAttrs, ssrInterpolate, ssrRenderClass, ssrRenderList, ssrIncludeBooleanAttr } from "vue/server-renderer";
import "/app/node_modules/hookable/dist/index.mjs";
import "/app/node_modules/klona/dist/index.mjs";
import "../server.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 "/app/node_modules/defu/dist/defu.mjs";
import "vue-router";
import "/app/node_modules/ufo/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 featureFlags = ref({
tier: "free",
features: {},
expires_at: null
});
const permissionMatrix = ref([]);
const allActions = ref([]);
const modifiedPermissions = ref(/* @__PURE__ */ new Map());
ref(/* @__PURE__ */ new Map());
const saveNotification = ref(null);
const featureEntries = computed(() => {
return Object.entries(featureFlags.value.features || {});
});
const hasModifications = computed(() => {
return modifiedPermissions.value.size > 0;
});
const tierBadgeClass = computed(() => {
const tier = featureFlags.value.tier;
if (tier === "enterprise") return "bg-purple-500/20 text-purple-300";
if (tier === "premium") return "bg-amber-500/20 text-amber-300";
return "bg-slate-500/20 text-slate-300";
});
const superadminPerms = [
{ key: "user_mgmt", label: "User Management", enabled: true },
{ key: "billing_admin", label: "Billing Administration", enabled: true },
{ key: "robot_config", label: "Robot Configuration", enabled: true },
{ key: "system_logs", label: "System Logs Access", enabled: true },
{ key: "api_keys", label: "API Key Management", enabled: false }
];
const garagePerms = [
{ key: "vehicle_crud", label: "Vehicle CRUD", enabled: true },
{ key: "service_booking", label: "Service Booking", enabled: true },
{ key: "customer_view", label: "Customer Data View", enabled: true },
{ key: "report_export", label: "Report Export", enabled: false },
{ key: "bulk_import", label: "Bulk Import", enabled: false }
];
function isPermEnabled(group, key) {
const mapKey = `${group}:${key}`;
if (modifiedPermissions.value.has(mapKey)) {
return modifiedPermissions.value.get(mapKey);
}
const perms = group === "superadmin" ? superadminPerms : garagePerms;
const perm = perms.find((p) => p.key === key);
return perm ? perm.enabled : false;
}
function formatFeatureLabel(key) {
return key.replace(/^cost_category:/, "").replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
}
function formatDate(dateStr) {
try {
const d = new Date(dateStr);
return d.toLocaleDateString("en-GB", { day: "numeric", month: "short", year: "numeric" });
} catch {
return dateStr;
}
}
function hasPermission(role, action) {
return role.actions.includes(action);
}
return (_ctx, _push, _parent, _attrs) => {
_push(`<div${ssrRenderAttrs(_attrs)}><div class="mb-8"><h1 class="text-2xl font-bold text-white">${ssrInterpolate(_ctx.$t("permissions.title"))}</h1><p class="text-slate-400 mt-1">${ssrInterpolate(_ctx.$t("permissions.subtitle"))}</p></div>`);
if (loading.value) {
_push(`<div class="flex items-center justify-center py-20"><svg class="animate-spin h-8 w-8 text-indigo-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg><span class="ml-3 text-slate-400">${ssrInterpolate(_ctx.$t("permissions.loading"))}</span></div>`);
} else if (error.value) {
_push(`<div class="bg-red-500/10 border border-red-500/20 rounded-xl p-6 mb-8"><div class="flex items-center gap-3"><svg class="w-6 h-6 text-red-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg><div><h3 class="text-red-300 font-medium">${ssrInterpolate(_ctx.$t("permissions.error_title"))}</h3><p class="text-red-400/80 text-sm mt-1">${ssrInterpolate(error.value)}</p></div></div><button class="mt-4 px-4 py-2 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition">${ssrInterpolate(_ctx.$t("permissions.retry"))}</button></div>`);
} else {
_push(`<!--[-->`);
if (saveNotification.value) {
_push(`<div class="${ssrRenderClass([saveNotification.value.type === "success" ? "bg-emerald-500/10 border border-emerald-500/20 text-emerald-300" : "bg-red-500/10 border border-red-500/20 text-red-300", "mb-6 px-4 py-3 rounded-lg text-sm font-medium"])}">${ssrInterpolate(saveNotification.value.message)}</div>`);
} else {
_push(`<!---->`);
}
if (hasModifications.value) {
_push(`<div class="mb-6 flex items-center gap-3"><button class="px-6 py-2.5 bg-emerald-600 hover:bg-emerald-500 text-white font-semibold rounded-lg shadow-lg shadow-emerald-600/20 transition-all hover:scale-[1.02] active:scale-[0.98] flex items-center gap-2"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4"></path></svg> ${ssrInterpolate(_ctx.$t("permissions.save_changes"))}</button><span class="text-sm text-slate-400">${ssrInterpolate(_ctx.$t("permissions.modified_count", { count: modifiedPermissions.value.size }))}</span></div>`);
} else {
_push(`<!---->`);
}
_push(`<div class="bg-indigo-500/10 border border-indigo-500/20 rounded-xl p-4 mb-8 flex items-start gap-3"><svg class="w-5 h-5 text-indigo-400 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg><div class="text-sm text-indigo-300"><span class="font-semibold">${ssrInterpolate(_ctx.$t("permissions.current_tier"))}:</span><span class="${ssrRenderClass([tierBadgeClass.value, "ml-2 px-2 py-0.5 rounded-full text-xs font-medium"])}">${ssrInterpolate(featureFlags.value.tier || "free")}</span>`);
if (featureFlags.value.expires_at) {
_push(`<span class="ml-3 text-indigo-400/70">${ssrInterpolate(_ctx.$t("permissions.expires"))}: ${ssrInterpolate(formatDate(featureFlags.value.expires_at))}</span>`);
} else {
_push(`<!---->`);
}
_push(`</div></div><div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8"><div class="bg-slate-800 rounded-xl border border-slate-700 p-6"><div class="flex items-center gap-3 mb-4"><div class="p-2 rounded-lg bg-purple-500/10 text-purple-400"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z"></path></svg></div><h2 class="text-lg font-semibold text-white">${ssrInterpolate(_ctx.$t("permissions.superadmin"))}</h2></div><p class="text-sm text-slate-400 mb-4">${ssrInterpolate(_ctx.$t("permissions.superadmin_desc"))}</p><div class="space-y-3"><!--[-->`);
ssrRenderList(superadminPerms, (perm) => {
_push(`<div class="flex items-center justify-between py-2 border-b border-slate-700/50 last:border-0"><span class="text-sm text-slate-300">${ssrInterpolate(_ctx.$t(`permissions.perms.${perm.key}`))}</span><label class="relative inline-flex items-center cursor-pointer"><input type="checkbox"${ssrIncludeBooleanAttr(isPermEnabled("superadmin", perm.key)) ? " checked" : ""} class="sr-only peer"><div class="w-9 h-5 bg-slate-600 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-purple-500/50 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[&#39;&#39;] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-slate-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-purple-600"></div></label></div>`);
});
_push(`<!--]--></div></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-6"><div class="flex items-center gap-3 mb-4"><div class="p-2 rounded-lg bg-cyan-500/10 text-cyan-400"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.25 18.75a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m3 0h6m-9 0H3.375a1.125 1.125 0 01-1.125-1.125V14.25m17.25 4.5a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m3 0h1.125c.621 0 1.129-.504 1.09-1.124a17.902 17.902 0 00-3.213-9.193 2.056 2.056 0 00-1.58-.86H14.25M16.5 18.75h-2.25m0-11.177v-.958c0-.568-.422-1.048-.987-1.106a48.554 48.554 0 00-10.026 0 1.106 1.106 0 00-.987 1.106v7.635m12-6.677v6.677m0 4.5v-4.5m0 0h-12"></path></svg></div><h2 class="text-lg font-semibold text-white">${ssrInterpolate(_ctx.$t("permissions.garages"))}</h2></div><p class="text-sm text-slate-400 mb-4">${ssrInterpolate(_ctx.$t("permissions.garages_desc"))}</p><div class="space-y-3"><!--[-->`);
ssrRenderList(garagePerms, (perm) => {
_push(`<div class="flex items-center justify-between py-2 border-b border-slate-700/50 last:border-0"><span class="text-sm text-slate-300">${ssrInterpolate(_ctx.$t(`permissions.perms.${perm.key}`))}</span><label class="relative inline-flex items-center cursor-pointer"><input type="checkbox"${ssrIncludeBooleanAttr(isPermEnabled("garage", perm.key)) ? " checked" : ""} class="sr-only peer"><div class="w-9 h-5 bg-slate-600 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-cyan-500/50 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[&#39;&#39;] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-slate-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-cyan-600"></div></label></div>`);
});
_push(`<!--]--></div></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-6"><div class="flex items-center gap-3 mb-4"><div class="p-2 rounded-lg bg-amber-500/10 text-amber-400"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5m8.25 3v6.75m0 0l-3-3m3 3l3-3M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z"></path></svg></div><h2 class="text-lg font-semibold text-white">${ssrInterpolate(_ctx.$t("permissions.feature_flags"))}</h2></div><p class="text-sm text-slate-400 mb-4">${ssrInterpolate(_ctx.$t("permissions.feature_flags_desc", { tier: featureFlags.value.tier || "free" }))}</p><div class="space-y-3"><!--[-->`);
ssrRenderList(featureEntries.value, ([key, granted]) => {
_push(`<div class="flex items-center justify-between py-2 border-b border-slate-700/50 last:border-0"><div class="flex flex-col"><span class="text-sm text-slate-300">${ssrInterpolate(formatFeatureLabel(key))}</span><span class="text-xs text-slate-500">${ssrInterpolate(key)}</span></div><label class="relative inline-flex items-center cursor-pointer"><input type="checkbox"${ssrIncludeBooleanAttr(granted) ? " checked" : ""} class="sr-only peer"${ssrIncludeBooleanAttr(true) ? " disabled" : ""}><div class="${ssrRenderClass([granted ? "peer-checked:bg-amber-600" : "", "w-9 h-5 bg-slate-600 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-amber-500/50 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-slate-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all"])}"></div></label></div>`);
});
_push(`<!--]--></div></div></div><div class="bg-slate-800/50 border border-slate-700 rounded-xl p-6 mb-8"><h3 class="text-lg font-semibold text-white mb-4">${ssrInterpolate(_ctx.$t("permissions.rbac_title"))}</h3><p class="text-sm text-slate-400 mb-6">${ssrInterpolate(_ctx.$t("permissions.rbac_desc"))}</p><div class="overflow-x-auto"><table class="w-full text-sm"><thead><tr class="border-b border-slate-700"><th class="text-left py-3 px-4 text-slate-400 font-medium">${ssrInterpolate(_ctx.$t("permissions.action"))}</th><!--[-->`);
ssrRenderList(permissionMatrix.value, (role) => {
_push(`<th class="text-center py-3 px-4 text-slate-400 font-medium">${ssrInterpolate(role.role)}</th>`);
});
_push(`<!--]--></tr></thead><tbody><!--[-->`);
ssrRenderList(allActions.value, (action) => {
_push(`<tr class="border-b border-slate-700/50 hover:bg-slate-700/30"><td class="py-2.5 px-4 text-slate-300">${ssrInterpolate(action)}</td><!--[-->`);
ssrRenderList(permissionMatrix.value, (role) => {
_push(`<td class="text-center py-2.5 px-4">`);
if (hasPermission(role, action)) {
_push(`<span class="inline-flex items-center justify-center w-6 h-6 rounded-full bg-emerald-400/10"><svg class="w-4 h-4 text-emerald-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg></span>`);
} else {
_push(`<span class="inline-flex items-center justify-center w-6 h-6 rounded-full bg-slate-700"><svg class="w-4 h-4 text-slate-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg></span>`);
}
_push(`</td>`);
});
_push(`<!--]--></tr>`);
});
_push(`<!--]--></tbody></table></div></div>`);
if (hasModifications.value) {
_push(`<div class="flex items-center gap-3 pb-8"><button class="px-6 py-2.5 bg-emerald-600 hover:bg-emerald-500 text-white font-semibold rounded-lg shadow-lg shadow-emerald-600/20 transition-all hover:scale-[1.02] active:scale-[0.98] flex items-center gap-2"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4"></path></svg> ${ssrInterpolate(_ctx.$t("permissions.save_changes"))}</button><button class="px-4 py-2.5 bg-slate-700 hover:bg-slate-600 text-slate-300 font-medium rounded-lg transition">${ssrInterpolate(_ctx.$t("permissions.discard"))}</button></div>`);
} else {
_push(`<!---->`);
}
_push(`<!--]-->`);
}
_push(`</div>`);
};
}
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/permissions/index.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
export {
_sfc_main as default
};
//# sourceMappingURL=index-7zBAzpaD.js.map