127 lines
14 KiB
JavaScript
127 lines
14 KiB
JavaScript
import { _ as __nuxt_component_0 } from "./nuxt-link-1NBbHb-h.js";
|
||
import { defineComponent, ref, unref, withCtx, createTextVNode, toDisplayString, openBlock, createBlock, createVNode, useSSRContext } from "vue";
|
||
import { ssrRenderAttrs, ssrInterpolate, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrRenderAttr, ssrRenderComponent, ssrRenderClass } from "vue/server-renderer";
|
||
import "/app/node_modules/hookable/dist/index.mjs";
|
||
import { u as useFormatter } from "./useFormatter-hycy3urM.js";
|
||
import "/app/node_modules/klona/dist/index.mjs";
|
||
import { a as useI18n } from "../server.mjs";
|
||
import "/app/node_modules/ufo/dist/index.mjs";
|
||
import "/app/node_modules/defu/dist/defu.mjs";
|
||
import "./region-0mvXqaMM.js";
|
||
import "pinia";
|
||
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 "vue-router";
|
||
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 { t } = useI18n();
|
||
const { formatNumber, formatDate } = useFormatter();
|
||
const loading = ref(false);
|
||
const error = ref(false);
|
||
const users = ref([]);
|
||
const totalCount = ref(0);
|
||
const offset = ref(0);
|
||
const limit = ref(50);
|
||
const filters = ref({
|
||
level: "",
|
||
min_xp: null,
|
||
max_xp: null,
|
||
has_penalty: ""
|
||
});
|
||
function restrictionLabel(level) {
|
||
switch (level) {
|
||
case 1:
|
||
return t("gamification.users.restriction_mild");
|
||
case 2:
|
||
return t("gamification.users.restriction_moderate");
|
||
case 3:
|
||
return t("gamification.users.restriction_severe");
|
||
default:
|
||
return `${level}. ${t("gamification.users.restriction_level")}`;
|
||
}
|
||
}
|
||
return (_ctx, _push, _parent, _attrs) => {
|
||
const _component_NuxtLink = __nuxt_component_0;
|
||
_push(`<div${ssrRenderAttrs(_attrs)}><div class="mb-8"><h1 class="text-2xl font-bold text-white">${ssrInterpolate(unref(t)("gamification.users.title"))}</h1><p class="text-slate-400 mt-1">${ssrInterpolate(unref(t)("gamification.users.subtitle"))}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-4 mb-6"><div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4"><div><label class="block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.filter_level"))}</label><select class="w-full bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-sm text-white focus:ring-2 focus:ring-indigo-500 focus:border-transparent"><option value=""${ssrIncludeBooleanAttr(Array.isArray(unref(filters).level) ? ssrLooseContain(unref(filters).level, "") : ssrLooseEqual(unref(filters).level, "")) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.users.all_levels"))}</option><!--[-->`);
|
||
ssrRenderList(20, (lvl) => {
|
||
_push(`<option${ssrRenderAttr("value", lvl)}${ssrIncludeBooleanAttr(Array.isArray(unref(filters).level) ? ssrLooseContain(unref(filters).level, lvl) : ssrLooseEqual(unref(filters).level, lvl)) ? " selected" : ""}>${ssrInterpolate(lvl)}. ${ssrInterpolate(unref(t)("gamification.users.level_suffix"))}</option>`);
|
||
});
|
||
_push(`<!--]--></select></div><div><label class="block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.filter_min_xp"))}</label><input${ssrRenderAttr("value", unref(filters).min_xp)} type="number" min="0" placeholder="0" class="w-full bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-sm text-white focus:ring-2 focus:ring-indigo-500 focus:border-transparent"></div><div><label class="block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.filter_max_xp"))}</label><input${ssrRenderAttr("value", unref(filters).max_xp)} type="number" min="0" placeholder="100000" class="w-full bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-sm text-white focus:ring-2 focus:ring-indigo-500 focus:border-transparent"></div><div><label class="block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.filter_penalty"))}</label><select class="w-full bg-slate-700 border border-slate-600 rounded-lg px-3 py-2 text-sm text-white focus:ring-2 focus:ring-indigo-500 focus:border-transparent"><option value=""${ssrIncludeBooleanAttr(Array.isArray(unref(filters).has_penalty) ? ssrLooseContain(unref(filters).has_penalty, "") : ssrLooseEqual(unref(filters).has_penalty, "")) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.users.penalty_any"))}</option><option${ssrRenderAttr("value", true)}${ssrIncludeBooleanAttr(Array.isArray(unref(filters).has_penalty) ? ssrLooseContain(unref(filters).has_penalty, true) : ssrLooseEqual(unref(filters).has_penalty, true)) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.users.penalty_only"))}</option><option${ssrRenderAttr("value", false)}${ssrIncludeBooleanAttr(Array.isArray(unref(filters).has_penalty) ? ssrLooseContain(unref(filters).has_penalty, false) : ssrLooseEqual(unref(filters).has_penalty, false)) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.users.penalty_none"))}</option></select></div></div><div class="flex items-center gap-3 mt-4 pt-4 border-t border-slate-700/50"><button class="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition">${ssrInterpolate(unref(t)("gamification.users.filter_apply"))}</button><button class="px-4 py-2 bg-slate-700 hover:bg-slate-600 text-slate-300 text-sm font-medium rounded-lg transition">${ssrInterpolate(unref(t)("gamification.users.filter_reset"))}</button><span class="text-xs text-slate-500 ml-auto">${ssrInterpolate(unref(t)("gamification.users.total_count", { count: unref(totalCount) }))}</span></div></div>`);
|
||
if (unref(loading)) {
|
||
_push(`<div class="flex items-center justify-center py-20"><div class="text-slate-400 flex items-center gap-3"><svg class="w-5 h-5 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path></svg><span>${ssrInterpolate(unref(t)("gamification.users.loading"))}</span></div></div>`);
|
||
} else if (unref(error)) {
|
||
_push(`<div class="bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8"><p class="text-rose-400">${ssrInterpolate(unref(t)("gamification.users.load_error"))}</p><button class="mt-3 text-sm text-rose-300 hover:text-rose-200 underline">${ssrInterpolate(unref(t)("gamification.users.retry"))}</button></div>`);
|
||
} else if (unref(users).length === 0) {
|
||
_push(`<div class="bg-slate-800 rounded-xl border border-slate-700 p-6"><p class="text-slate-400 text-center py-12">${ssrInterpolate(unref(t)("gamification.users.empty"))}</p></div>`);
|
||
} else {
|
||
_push(`<div class="bg-slate-800 rounded-xl border border-slate-700 overflow-hidden"><div class="overflow-x-auto"><table class="w-full"><thead><tr class="border-b border-slate-700"><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_user_id"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_xp"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_level"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_points"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_penalty"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_restriction"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_services"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_discoveries"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_updated"))}</th><th class="text-right px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.users.col_actions"))}</th></tr></thead><tbody class="divide-y divide-slate-700/50"><!--[-->`);
|
||
ssrRenderList(unref(users), (user) => {
|
||
_push(`<tr class="hover:bg-slate-700/30 transition"><td class="px-4 py-3 text-sm text-white font-mono">#${ssrInterpolate(user.user_id)}</td><td class="px-4 py-3 text-sm text-white">${ssrInterpolate(unref(formatNumber)(user.total_xp))}</td><td class="px-4 py-3"><span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-indigo-500/10 text-indigo-400 border border-indigo-500/20">${ssrInterpolate(user.current_level)}</span></td><td class="px-4 py-3 text-sm text-slate-300">${ssrInterpolate(unref(formatNumber)(user.total_points))}</td><td class="px-4 py-3">`);
|
||
if (user.penalty_points > 0) {
|
||
_push(`<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-rose-500/10 text-rose-400 border border-rose-500/20"> -${ssrInterpolate(user.penalty_points)}</span>`);
|
||
} else {
|
||
_push(`<span class="text-sm text-slate-500">—</span>`);
|
||
}
|
||
_push(`</td><td class="px-4 py-3">`);
|
||
if (user.restriction_level > 0) {
|
||
_push(`<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-amber-500/10 text-amber-400 border border-amber-500/20">${ssrInterpolate(restrictionLabel(user.restriction_level))}</span>`);
|
||
} else {
|
||
_push(`<span class="text-sm text-slate-500">${ssrInterpolate(unref(t)("gamification.users.none"))}</span>`);
|
||
}
|
||
_push(`</td><td class="px-4 py-3 text-sm text-slate-300">${ssrInterpolate(user.services_submitted)}</td><td class="px-4 py-3 text-sm text-slate-300">${ssrInterpolate(user.places_discovered)}</td><td class="px-4 py-3 text-sm text-slate-500">${ssrInterpolate(user.updated_at ? unref(formatDate)(user.updated_at) : "—")}</td><td class="px-4 py-3 text-right">`);
|
||
_push(ssrRenderComponent(_component_NuxtLink, {
|
||
to: `/gamification/users/${user.user_id}`,
|
||
class: "inline-flex items-center gap-1.5 px-3 py-1.5 bg-indigo-600/10 hover:bg-indigo-600/20 text-indigo-400 text-xs font-medium rounded-lg transition"
|
||
}, {
|
||
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
||
if (_push2) {
|
||
_push2(`${ssrInterpolate(unref(t)("gamification.users.details"))} <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"${_scopeId}><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"${_scopeId}></path></svg>`);
|
||
} else {
|
||
return [
|
||
createTextVNode(toDisplayString(unref(t)("gamification.users.details")) + " ", 1),
|
||
(openBlock(), createBlock("svg", {
|
||
class: "w-3.5 h-3.5",
|
||
fill: "none",
|
||
stroke: "currentColor",
|
||
viewBox: "0 0 24 24"
|
||
}, [
|
||
createVNode("path", {
|
||
"stroke-linecap": "round",
|
||
"stroke-linejoin": "round",
|
||
"stroke-width": "2",
|
||
d: "M9 5l7 7-7 7"
|
||
})
|
||
]))
|
||
];
|
||
}
|
||
}),
|
||
_: 2
|
||
}, _parent));
|
||
_push(`</td></tr>`);
|
||
});
|
||
_push(`<!--]--></tbody></table></div><div class="flex items-center justify-between px-4 py-3 border-t border-slate-700"><button${ssrIncludeBooleanAttr(unref(offset) === 0) ? " disabled" : ""} class="${ssrRenderClass([unref(offset) === 0 ? "text-slate-600 cursor-not-allowed" : "text-slate-300 hover:bg-slate-700", "px-3 py-1.5 text-sm rounded-lg transition"])}">${ssrInterpolate(unref(t)("gamification.users.prev"))}</button><span class="text-sm text-slate-500">${ssrInterpolate(unref(offset) + 1)}–${ssrInterpolate(Math.min(unref(offset) + unref(limit), unref(totalCount)))} / ${ssrInterpolate(unref(totalCount))}</span><button${ssrIncludeBooleanAttr(unref(offset) + unref(limit) >= unref(totalCount)) ? " disabled" : ""} class="${ssrRenderClass([unref(offset) + unref(limit) >= unref(totalCount) ? "text-slate-600 cursor-not-allowed" : "text-slate-300 hover:bg-slate-700", "px-3 py-1.5 text-sm rounded-lg transition"])}">${ssrInterpolate(unref(t)("gamification.users.next"))}</button></div></div>`);
|
||
}
|
||
_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/gamification/users/index.vue");
|
||
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
||
};
|
||
export {
|
||
_sfc_main as default
|
||
};
|
||
//# sourceMappingURL=index-B4tBHEvj.js.map
|