135 lines
18 KiB
JavaScript
135 lines
18 KiB
JavaScript
import { defineComponent, computed, ref, unref, useSSRContext } from 'vue';
|
|
import { ssrRenderAttrs, ssrInterpolate, ssrRenderClass, ssrRenderAttr, ssrIncludeBooleanAttr, ssrRenderList } from 'vue/server-renderer';
|
|
import { u as useFormatter } from './useFormatter-hycy3urM.mjs';
|
|
import { a as useI18n, b as useRouter, i as useRoute } from './server.mjs';
|
|
import './region-0mvXqaMM.mjs';
|
|
import 'pinia';
|
|
import '../nitro/nitro.mjs';
|
|
import 'node:http';
|
|
import 'node:https';
|
|
import 'node:events';
|
|
import 'node:buffer';
|
|
import 'node:fs';
|
|
import 'node:path';
|
|
import 'node:crypto';
|
|
import 'vue-router';
|
|
import 'node:url';
|
|
import '../routes/renderer.mjs';
|
|
import 'vue-bundle-renderer/runtime';
|
|
import 'unhead/server';
|
|
import 'devalue';
|
|
import 'unhead/utils';
|
|
import 'unhead/plugins';
|
|
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "[id]",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const { t } = useI18n();
|
|
const { formatNumber, formatDate, formatDateTime } = useFormatter();
|
|
useRouter();
|
|
const route = useRoute();
|
|
computed(() => Number(route.params.id));
|
|
const loading = ref(true);
|
|
const error = ref(false);
|
|
const stats = ref(null);
|
|
const ledger = ref([]);
|
|
const ledgerLoading = ref(false);
|
|
const penaltyForm = ref({ amount: 0, reason: "" });
|
|
const penaltySubmitting = ref(false);
|
|
const penaltyError = ref("");
|
|
const penaltySuccess = ref("");
|
|
const rewardForm = ref({ xp_amount: 0, social_amount: 0, reason: "" });
|
|
const rewardSubmitting = ref(false);
|
|
const rewardError = ref("");
|
|
const rewardSuccess = ref("");
|
|
function restrictionLabel(level) {
|
|
switch (level) {
|
|
case 1:
|
|
return t("gamification.user_detail.restriction_mild");
|
|
case 2:
|
|
return t("gamification.user_detail.restriction_moderate");
|
|
case 3:
|
|
return t("gamification.user_detail.restriction_severe");
|
|
default:
|
|
return `${level}. ${t("gamification.user_detail.restriction_level")}`;
|
|
}
|
|
}
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(`<div${ssrRenderAttrs(_attrs)}><div class="mb-8"><button class="inline-flex items-center gap-1.5 text-sm text-slate-400 hover:text-white transition mb-4"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path></svg> ${ssrInterpolate(unref(t)("gamification.user_detail.back"))}</button><h1 class="text-2xl font-bold text-white">${ssrInterpolate(unref(t)("gamification.user_detail.title"))}</h1><p class="text-slate-400 mt-1">${ssrInterpolate(unref(t)("gamification.user_detail.user_id"))} #${ssrInterpolate(_ctx.$route.params.id)}</p></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.user_detail.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.user_detail.load_error"))}</p><button class="mt-3 text-sm text-rose-300 hover:text-rose-200 underline">${ssrInterpolate(unref(t)("gamification.user_detail.retry"))}</button></div>`);
|
|
} else if (!unref(stats)) {
|
|
_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.user_detail.not_found"))}</p></div>`);
|
|
} else {
|
|
_push(`<!--[--><div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4 mb-8"><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_total_xp"))}</h3><p class="text-2xl font-bold text-white">${ssrInterpolate(unref(formatNumber)(unref(stats).total_xp))}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_level"))}</h3><p class="text-2xl font-bold text-indigo-400">${ssrInterpolate(unref(stats).current_level)}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_total_points"))}</h3><p class="text-2xl font-bold text-emerald-400">${ssrInterpolate(unref(formatNumber)(unref(stats).total_points))}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_social_points"))}</h3><p class="text-2xl font-bold text-cyan-400">${ssrInterpolate(unref(formatNumber)(unref(stats).social_points))}</p></div></div><div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4 mb-8"><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_penalty_points"))}</h3><p class="${ssrRenderClass([unref(stats).penalty_points > 0 ? "text-rose-400" : "text-slate-400", "text-2xl font-bold"])}">${ssrInterpolate(unref(stats).penalty_points > 0 ? `-${unref(stats).penalty_points}` : "0")}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_restriction"))}</h3><p class="${ssrRenderClass([unref(stats).restriction_level > 0 ? "text-amber-400" : "text-slate-400", "text-2xl font-bold"])}">${ssrInterpolate(unref(stats).restriction_level > 0 ? restrictionLabel(unref(stats).restriction_level) : unref(t)("gamification.user_detail.none"))}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_penalty_quota"))}</h3><p class="text-2xl font-bold text-slate-300">${ssrInterpolate(unref(stats).penalty_quota_remaining)}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_banned"))}</h3><p class="${ssrRenderClass([unref(stats).banned_until ? "text-rose-400" : "text-slate-400", "text-2xl font-bold"])}">${ssrInterpolate(unref(stats).banned_until ? unref(formatDate)(unref(stats).banned_until) : unref(t)("gamification.user_detail.no"))}</p></div></div><div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4 mb-8"><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_services"))}</h3><p class="text-2xl font-bold text-white">${ssrInterpolate(unref(stats).services_submitted)}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_discovered"))}</h3><p class="text-2xl font-bold text-white">${ssrInterpolate(unref(stats).places_discovered)}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_validated"))}</h3><p class="text-2xl font-bold text-white">${ssrInterpolate(unref(stats).places_validated)}</p></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-5"><h3 class="text-xs font-medium text-slate-400 uppercase tracking-wider mb-1">${ssrInterpolate(unref(t)("gamification.user_detail.stat_providers"))}</h3><p class="text-2xl font-bold text-white">${ssrInterpolate(unref(stats).providers_added_count)}</p></div></div><div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8"><div class="bg-slate-800 rounded-xl border border-slate-700 p-6"><h2 class="text-lg font-semibold text-white mb-4 flex items-center gap-2"><svg class="w-5 h-5 text-rose-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"></path></svg> ${ssrInterpolate(unref(t)("gamification.user_detail.penalty_title"))}</h2><div class="space-y-4"><div><label class="block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.user_detail.penalty_points_label"))}</label><input${ssrRenderAttr("value", unref(penaltyForm).amount)} type="number" min="1" max="10000" placeholder="1\u201310000" 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-rose-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.user_detail.penalty_reason_label"))}</label><textarea rows="2"${ssrRenderAttr("placeholder", unref(t)("gamification.user_detail.penalty_reason_placeholder"))} 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-rose-500 focus:border-transparent resize-none">${ssrInterpolate(unref(penaltyForm).reason)}</textarea></div><button${ssrIncludeBooleanAttr(unref(penaltySubmitting) || !unref(penaltyForm).amount || !unref(penaltyForm).reason) ? " disabled" : ""} class="w-full px-4 py-2.5 bg-rose-600 hover:bg-rose-500 disabled:bg-rose-600/50 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg transition flex items-center justify-center gap-2">`);
|
|
if (unref(penaltySubmitting)) {
|
|
_push(`<svg class="w-4 h-4 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>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(` ${ssrInterpolate(unref(penaltySubmitting) ? unref(t)("gamification.user_detail.penalty_submitting") : unref(t)("gamification.user_detail.penalty_submit"))}</button>`);
|
|
if (unref(penaltyError)) {
|
|
_push(`<p class="text-xs text-rose-400">${ssrInterpolate(unref(penaltyError))}</p>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (unref(penaltySuccess)) {
|
|
_push(`<p class="text-xs text-emerald-400">${ssrInterpolate(unref(penaltySuccess))}</p>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-6"><h2 class="text-lg font-semibold text-white mb-4 flex items-center gap-2"><svg class="w-5 h-5 text-emerald-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> ${ssrInterpolate(unref(t)("gamification.user_detail.reward_title"))}</h2><div class="space-y-4"><div><label class="block text-xs font-medium text-slate-400 mb-1.5 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.user_detail.reward_xp_label"))}</label><input${ssrRenderAttr("value", unref(rewardForm).xp_amount)} type="number" min="0" max="100000" placeholder="0\u2013100000" 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-emerald-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.user_detail.reward_social_label"))}</label><input${ssrRenderAttr("value", unref(rewardForm).social_amount)} type="number" min="0" max="100000" placeholder="0\u2013100000" 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-emerald-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.user_detail.reward_reason_label"))}</label><textarea rows="2"${ssrRenderAttr("placeholder", unref(t)("gamification.user_detail.reward_reason_placeholder"))} 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-emerald-500 focus:border-transparent resize-none">${ssrInterpolate(unref(rewardForm).reason)}</textarea></div><button${ssrIncludeBooleanAttr(unref(rewardSubmitting) || !unref(rewardForm).xp_amount || !unref(rewardForm).reason) ? " disabled" : ""} class="w-full px-4 py-2.5 bg-emerald-600 hover:bg-emerald-500 disabled:bg-emerald-600/50 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg transition flex items-center justify-center gap-2">`);
|
|
if (unref(rewardSubmitting)) {
|
|
_push(`<svg class="w-4 h-4 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>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(` ${ssrInterpolate(unref(rewardSubmitting) ? unref(t)("gamification.user_detail.reward_submitting") : unref(t)("gamification.user_detail.reward_submit"))}</button>`);
|
|
if (unref(rewardError)) {
|
|
_push(`<p class="text-xs text-rose-400">${ssrInterpolate(unref(rewardError))}</p>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (unref(rewardSuccess)) {
|
|
_push(`<p class="text-xs text-emerald-400">${ssrInterpolate(unref(rewardSuccess))}</p>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div></div></div><div class="bg-slate-800 rounded-xl border border-slate-700 p-6 mb-8"><div class="flex items-center justify-between mb-4"><h2 class="text-lg font-semibold text-white">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_title"))}</h2><span class="text-xs text-slate-500">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_count", { count: unref(ledger).length }))}</span></div>`);
|
|
if (unref(ledgerLoading)) {
|
|
_push(`<div class="flex items-center justify-center py-8"><div class="text-slate-400 flex items-center gap-2"><svg class="w-4 h-4 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.user_detail.ledger_loading"))}</span></div></div>`);
|
|
} else if (unref(ledger).length === 0) {
|
|
_push(`<div class="text-sm text-slate-500 text-center py-8">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_empty"))}</div>`);
|
|
} else {
|
|
_push(`<div class="overflow-x-auto"><table class="w-full"><thead><tr class="border-b border-slate-700"><th class="text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_col_date"))}</th><th class="text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_col_points"))}</th><th class="text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_col_penalty"))}</th><th class="text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_col_xp"))}</th><th class="text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_col_reason"))}</th><th class="text-left px-3 py-2 text-xs font-medium text-slate-400 uppercase tracking-wider">${ssrInterpolate(unref(t)("gamification.user_detail.ledger_col_source"))}</th></tr></thead><tbody class="divide-y divide-slate-700/50"><!--[-->`);
|
|
ssrRenderList(unref(ledger), (entry) => {
|
|
var _a;
|
|
_push(`<tr class="hover:bg-slate-700/30 transition"><td class="px-3 py-2.5 text-xs text-slate-400 whitespace-nowrap">${ssrInterpolate(unref(formatDateTime)(entry.created_at))}</td><td class="${ssrRenderClass([entry.points >= 0 ? "text-emerald-400" : "text-rose-400", "px-3 py-2.5 text-sm font-medium"])}">${ssrInterpolate(entry.points >= 0 ? "+" : "")}${ssrInterpolate(entry.points)}</td><td class="${ssrRenderClass([entry.penalty_change ? "text-rose-400" : "text-slate-500", "px-3 py-2.5 text-sm"])}">${ssrInterpolate(entry.penalty_change ? `-${entry.penalty_change}` : "\u2014")}</td><td class="px-3 py-2.5 text-sm text-slate-300">${ssrInterpolate((_a = entry.xp) != null ? _a : "\u2014")}</td><td class="px-3 py-2.5 text-sm text-slate-300 max-w-xs truncate">${ssrInterpolate(entry.reason)}</td><td class="px-3 py-2.5 text-xs text-slate-500">`);
|
|
if (entry.source_type) {
|
|
_push(`<span class="inline-flex items-center px-2 py-0.5 rounded text-xs bg-slate-700 text-slate-400">${ssrInterpolate(entry.source_type)}${ssrInterpolate(entry.source_id ? ` #${entry.source_id}` : "")}</span>`);
|
|
} else {
|
|
_push(`<span>\u2014</span>`);
|
|
}
|
|
_push(`</td></tr>`);
|
|
});
|
|
_push(`<!--]--></tbody></table></div>`);
|
|
}
|
|
_push(`</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/[id].vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
|
|
export { _sfc_main as default };
|
|
//# sourceMappingURL=_id_-DvpH9xyV.mjs.map
|