import { _ as __nuxt_component_0 } from "./nuxt-link-Ci8vU-Yt.js"; import { defineComponent, ref, computed, withCtx, createTextVNode, toDisplayString, useSSRContext } from "vue"; import { ssrRenderAttrs, ssrInterpolate, ssrRenderClass, ssrRenderList, ssrRenderComponent, ssrRenderTeleport, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain } from "vue/server-renderer"; import { useRoute, useRouter } from "vue-router"; import { c as useAuthStore } from "../server.mjs"; import "/app/node_modules/klona/dist/index.mjs"; import "/app/node_modules/hookable/dist/index.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 "/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 route = useRoute(); useRouter(); const auth = useAuthStore(); route.params.id; const loading = ref(true); const error = ref(null); const person = ref(null); const activeTab = ref("profile"); const showEditModal = ref(false); const saving = ref(false); const editForm = ref({ last_name: "", first_name: "", phone: "", mothers_last_name: "", mothers_first_name: "", birth_place: "", birth_date: "", is_active: true, is_ghost: false, is_sales_agent: false }); const notification = ref({ show: false, type: "success", message: "" }); const tabs = [ { key: "profile", label: "persons.details.profile_tab" }, { key: "users", label: "persons.details.users_tab" }, { key: "memberships", label: "persons.details.memberships_tab" }, { key: "owned_orgs", label: "persons.details.owned_orgs_tab" }, { key: "merge_history", label: "persons.details.merge_history_tab" } ]; const personDisplayName = computed(() => { if (!person.value) return ""; const p = person.value; if (p.last_name || p.first_name) { return [p.last_name, p.first_name].filter(Boolean).join(" "); } return "Person #" + p.id; }); const hasEditPermission = computed(() => { if (auth.isAdmin) return true; return !!auth.user?.system_capabilities?.["persons:edit"]; }); const hasIdentityDocs = computed(() => { if (!person.value?.identity_docs) return false; const docs = person.value.identity_docs; if (typeof docs === "object" && Object.keys(docs).length > 0) return true; return false; }); const hasIceContact = computed(() => { if (!person.value?.ice_contact) return false; const ice = person.value.ice_contact; if (typeof ice === "object" && Object.keys(ice).length > 0) return true; return false; }); function getInitials(name) { if (!name) return "?"; return name.split(" ").map((w) => w[0]).join("").toUpperCase().slice(0, 2); } function getInitialsColor(name) { const colors = [ "bg-red-500", "bg-yellow-500", "bg-green-500", "bg-blue-500", "bg-indigo-500", "bg-purple-500", "bg-pink-500", "bg-teal-500" ]; 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 formatDate(date) { if (!date) return ""; try { return new Date(date).toLocaleDateString("en-GB", { year: "numeric", month: "short", day: "numeric" }); } catch { return String(date); } } function formatJson(data) { if (!data) return ""; try { return JSON.stringify(data, null, 2); } catch { return String(data); } } function roleBadgeClass(role) { const map = { admin: "bg-purple-500/10 text-purple-400", user: "bg-blue-500/10 text-blue-400", staff: "bg-cyan-500/10 text-cyan-400", superadmin: "bg-amber-500/10 text-amber-400" }; return map[role?.toLowerCase()] || "bg-slate-500/10 text-slate-400"; } function planBadgeClass(plan) { const map = { FREE: "bg-slate-500/10 text-slate-400", PREMIUM: "bg-emerald-500/10 text-emerald-400", ENTERPRISE: "bg-amber-500/10 text-amber-400" }; return map[plan?.toUpperCase()] || "bg-slate-500/10 text-slate-400"; } function orgRoleBadgeClass(role) { const map = { admin: "bg-purple-500/10 text-purple-400", manager: "bg-blue-500/10 text-blue-400", member: "bg-slate-500/10 text-slate-400", owner: "bg-amber-500/10 text-amber-400" }; return map[role?.toLowerCase()] || "bg-slate-500/10 text-slate-400"; } function memberStatusBadgeClass(status) { const map = { active: "bg-emerald-500/10 text-emerald-400", invited: "bg-blue-500/10 text-blue-400", suspended: "bg-red-500/10 text-red-400", inactive: "bg-slate-500/10 text-slate-400" }; return map[status?.toLowerCase()] || "bg-slate-500/10 text-slate-400"; } function memberStatusDotClass(status) { const map = { active: "bg-emerald-400", invited: "bg-blue-400", suspended: "bg-red-400", inactive: "bg-slate-400" }; return map[status?.toLowerCase()] || "bg-slate-400"; } return (_ctx, _push, _parent, _attrs) => { const _component_NuxtLink = __nuxt_component_0; _push(``); if (loading.value) { _push(`

${ssrInterpolate(_ctx.$t("persons.details.loading"))}

`); } else if (error.value) { _push(`

${ssrInterpolate(error.value)}

`); } else if (person.value) { _push(`
${ssrInterpolate(getInitials(personDisplayName.value))}

${ssrInterpolate(personDisplayName.value)}

${ssrInterpolate(person.value.is_active ? _ctx.$t("persons.active") : _ctx.$t("persons.inactive"))}`); if (person.value.is_ghost) { _push(`${ssrInterpolate(_ctx.$t("persons.ghost"))}`); } else { _push(``); } if (person.value.merged_into_id) { _push(`${ssrInterpolate(_ctx.$t("persons.merged"))}`); } else { _push(``); } if (person.value.is_sales_agent) { _push(`${ssrInterpolate(_ctx.$t("persons.details.sales_agent"))}`); } else { _push(``); } _push(`

ID: ${ssrInterpolate(person.value.id)} `); if (person.value.phone) { _push(`· ${ssrInterpolate(person.value.phone)}`); } else { _push(``); } _push(`

`); if (hasEditPermission.value) { _push(``); } else { _push(``); } _push(`
`); if (activeTab.value === "profile") { _push(`

${ssrInterpolate(_ctx.$t("persons.details.personal_info"))}

${ssrInterpolate(person.value.id)}

${ssrInterpolate(person.value.id_uuid)}

${ssrInterpolate(person.value.last_name || "—")}

${ssrInterpolate(person.value.first_name || "—")}

${ssrInterpolate(person.value.phone || "—")}

${ssrInterpolate(person.value.birth_place || "—")}

${ssrInterpolate(formatDate(person.value.birth_date) || "—")}

${ssrInterpolate([person.value.mothers_last_name, person.value.mothers_first_name].filter(Boolean).join(" ") || "—")}

`); if (person.value.address) { _push(`

${ssrInterpolate(_ctx.$t("persons.details.address"))}

${ssrInterpolate(person.value.address.address_zip || "—")}

${ssrInterpolate(person.value.address.address_city || "—")}

${ssrInterpolate([person.value.address.address_street_type, person.value.address.address_street_name].filter(Boolean).join(" ") || "—")}

${ssrInterpolate(person.value.address.address_house_number || "—")}

${ssrInterpolate(person.value.address.address_stairwell || "—")}

${ssrInterpolate(person.value.address.address_floor || "—")}

${ssrInterpolate(person.value.address.address_door || "—")}

${ssrInterpolate(person.value.address.address_hrsz || "—")}

`); if (person.value.address.full_address_text) { _push(`

${ssrInterpolate(person.value.address.full_address_text)}

`); } else { _push(``); } _push(`
`); } else { _push(``); } _push(`

${ssrInterpolate(_ctx.$t("persons.details.system_info"))}

${ssrInterpolate(person.value.is_sales_agent ? _ctx.$t("persons.details.yes") : _ctx.$t("persons.details.no"))}

${ssrInterpolate(person.value.lifetime_xp)}

${ssrInterpolate(person.value.penalty_points)}

${ssrInterpolate(person.value.social_reputation.toFixed(2))}

${ssrInterpolate(formatDate(person.value.created_at) || "—")}

${ssrInterpolate(formatDate(person.value.updated_at) || "—")}

`); if (person.value.deleted_at) { _push(`

${ssrInterpolate(formatDate(person.value.deleted_at))}

`); } else { _push(``); } _push(`
`); if (hasIdentityDocs.value) { _push(`

${ssrInterpolate(_ctx.$t("persons.details.identity_docs"))}

${ssrInterpolate(formatJson(person.value.identity_docs))}
`); } else { _push(``); } if (hasIceContact.value) { _push(`

${ssrInterpolate(_ctx.$t("persons.details.ice_contact"))}

${ssrInterpolate(formatJson(person.value.ice_contact))}
`); } else { _push(``); } _push(`
`); } else { _push(``); } if (activeTab.value === "users") { _push(`

${ssrInterpolate(_ctx.$t("persons.details.connected_users"))}

${ssrInterpolate(_ctx.$t("persons.details.users_count", { count: person.value.users.length }))}

`); if (person.value.users.length === 0) { _push(`

${ssrInterpolate(_ctx.$t("persons.details.no_users"))}

`); } else { _push(`
`); ssrRenderList(person.value.users, (u) => { _push(``); }); _push(`
ID${ssrInterpolate(_ctx.$t("persons.details.email"))}${ssrInterpolate(_ctx.$t("persons.details.role"))}${ssrInterpolate(_ctx.$t("persons.details.status"))}${ssrInterpolate(_ctx.$t("persons.details.plan"))}${ssrInterpolate(_ctx.$t("persons.details.language"))}${ssrInterpolate(_ctx.$t("persons.details.registered_at"))}
`); _push(ssrRenderComponent(_component_NuxtLink, { to: "/users/" + u.id, class: "text-sm font-mono text-indigo-400 hover:underline" }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`${ssrInterpolate(u.id)}`); } else { return [ createTextVNode(toDisplayString(u.id), 1) ]; } }), _: 2 }, _parent)); _push(``); _push(ssrRenderComponent(_component_NuxtLink, { to: "/users/" + u.id, class: "text-sm font-medium text-white hover:text-indigo-400 hover:underline transition-colors" }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`${ssrInterpolate(u.email)}`); } else { return [ createTextVNode(toDisplayString(u.email), 1) ]; } }), _: 2 }, _parent)); _push(`${ssrInterpolate(u.role || "—")} ${ssrInterpolate(u.is_active ? _ctx.$t("persons.active") : _ctx.$t("persons.inactive"))}${ssrInterpolate(u.subscription_plan)}${ssrInterpolate(u.preferred_language?.toUpperCase() || "—")}${ssrInterpolate(formatDate(u.created_at) || "—")}
`); } _push(`
`); } else { _push(``); } if (activeTab.value === "memberships") { _push(`

${ssrInterpolate(_ctx.$t("persons.details.memberships"))}

${ssrInterpolate(_ctx.$t("persons.details.memberships_count", { count: person.value.memberships.length }))}

`); if (person.value.memberships.length === 0) { _push(`

${ssrInterpolate(_ctx.$t("persons.details.no_memberships"))}

`); } else { _push(`
`); ssrRenderList(person.value.memberships, (m) => { _push(``); }); _push(`
${ssrInterpolate(_ctx.$t("persons.details.org_name"))}${ssrInterpolate(_ctx.$t("persons.details.org_type"))}${ssrInterpolate(_ctx.$t("persons.details.org_role"))}${ssrInterpolate(_ctx.$t("persons.details.member_status"))}${ssrInterpolate(_ctx.$t("persons.details.verified"))}${ssrInterpolate(_ctx.$t("persons.details.joined_at"))}
`); _push(ssrRenderComponent(_component_NuxtLink, { to: "/garages/" + m.organization_id, class: "text-sm font-medium text-white hover:text-indigo-400 hover:underline transition-colors" }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`${ssrInterpolate(m.organization_name)}`); } else { return [ createTextVNode(toDisplayString(m.organization_name), 1) ]; } }), _: 2 }, _parent)); _push(`${ssrInterpolate(m.organization_type || "—")}${ssrInterpolate(m.role)} ${ssrInterpolate(m.status)}`); if (m.is_verified) { _push(` ${ssrInterpolate(_ctx.$t("persons.details.verified_yes"))}`); } else { _push(`${ssrInterpolate(_ctx.$t("persons.details.verified_no"))}`); } _push(`${ssrInterpolate(formatDate(m.created_at) || "—")}
`); } _push(`
`); } else { _push(``); } if (activeTab.value === "owned_orgs") { _push(`

${ssrInterpolate(_ctx.$t("persons.details.owned_orgs"))}

${ssrInterpolate(_ctx.$t("persons.details.owned_orgs_count", { count: person.value.owned_organizations.length }))}

`); if (person.value.owned_organizations.length === 0) { _push(`

${ssrInterpolate(_ctx.$t("persons.details.no_owned_orgs"))}

`); } else { _push(`
`); ssrRenderList(person.value.owned_organizations, (o) => { _push(``); }); _push(`
${ssrInterpolate(_ctx.$t("persons.details.org_name"))}${ssrInterpolate(_ctx.$t("persons.details.org_type"))}${ssrInterpolate(_ctx.$t("persons.details.status"))}${ssrInterpolate(_ctx.$t("persons.details.created_at"))}
`); _push(ssrRenderComponent(_component_NuxtLink, { to: "/garages/" + o.id, class: "text-sm font-medium text-white hover:text-indigo-400 hover:underline transition-colors" }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`${ssrInterpolate(o.name)}`); } else { return [ createTextVNode(toDisplayString(o.name), 1) ]; } }), _: 2 }, _parent)); _push(`${ssrInterpolate(o.org_type || "—")} ${ssrInterpolate(o.is_active ? _ctx.$t("persons.active") : _ctx.$t("persons.inactive"))}${ssrInterpolate(formatDate(o.created_at) || "—")}
`); } _push(`
`); } else { _push(``); } if (activeTab.value === "merge_history") { _push(`

${ssrInterpolate(_ctx.$t("persons.details.merge_history"))}

`); if (!person.value.merge_history) { _push(`

${ssrInterpolate(_ctx.$t("persons.details.no_merge_history"))}

`); } else { _push(`

${ssrInterpolate(_ctx.$t("persons.details.merged_into"))} `); _push(ssrRenderComponent(_component_NuxtLink, { to: "/persons/" + person.value.merge_history.merged_into_id, class: "text-indigo-400 hover:underline font-medium" }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`${ssrInterpolate(person.value.merge_history.merged_into_name || "#" + person.value.merge_history.merged_into_id)}`); } else { return [ createTextVNode(toDisplayString(person.value.merge_history.merged_into_name || "#" + person.value.merge_history.merged_into_id), 1) ]; } }), _: 1 }, _parent)); _push(`

${ssrInterpolate(_ctx.$t("persons.details.merged_at"))}: ${ssrInterpolate(formatDate(person.value.merge_history.merged_at))}

`); } _push(`
`); } else { _push(``); } ssrRenderTeleport(_push, (_push2) => { if (showEditModal.value) { _push2(`

${ssrInterpolate(_ctx.$t("persons.details.edit_title"))}

${ssrInterpolate(_ctx.$t("persons.details.personal_info"))}

${ssrInterpolate(_ctx.$t("persons.details.status_section"))}

`); if (saving.value) { _push2(``); } else { _push2(``); } _push2(` ${ssrInterpolate(saving.value ? _ctx.$t("persons.details.saving") : _ctx.$t("persons.details.save"))}
`); } else { _push2(``); } }, "body", false, _parent); ssrRenderTeleport(_push, (_push2) => { if (notification.value.show) { _push2(`
`); if (notification.value.type === "success") { _push2(``); } else { _push2(``); } _push2(`${ssrInterpolate(notification.value.message)}
`); } else { _push2(``); } }, "body", false, _parent); _push(``); } else { _push(``); } _push(``); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/persons/[id]/index.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; export { _sfc_main as default }; //# sourceMappingURL=index-DN4o4Z9u.js.map