120 lines
15 KiB
JavaScript
120 lines
15 KiB
JavaScript
import { defineComponent, ref, reactive, computed, unref, useSSRContext } from "vue";
|
|
import { ssrRenderAttrs, ssrInterpolate, ssrRenderAttr, ssrRenderList, ssrRenderClass, ssrIncludeBooleanAttr } from "vue/server-renderer";
|
|
import "/app/node_modules/hookable/dist/index.mjs";
|
|
import "/app/node_modules/klona/dist/index.mjs";
|
|
import { a as useI18n } from "../server.mjs";
|
|
import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
|
|
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: "ledger",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const { t } = useI18n();
|
|
const loading = ref(true);
|
|
const error = ref(false);
|
|
const entries = ref([]);
|
|
const total = ref(0);
|
|
const offset = ref(0);
|
|
const limit = ref(50);
|
|
const toast = ref("");
|
|
const filters = reactive({
|
|
user_id: null,
|
|
date_from: "",
|
|
date_to: "",
|
|
reason_search: ""
|
|
});
|
|
const currentPage = computed(() => Math.floor(offset.value / limit.value) + 1);
|
|
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / limit.value)));
|
|
function formatDate(dateStr) {
|
|
if (!dateStr) return "—";
|
|
const d = new Date(dateStr);
|
|
return d.toLocaleDateString("hu-HU", {
|
|
year: "numeric",
|
|
month: "2-digit",
|
|
day: "2-digit",
|
|
hour: "2-digit",
|
|
minute: "2-digit"
|
|
});
|
|
}
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(`<div${ssrRenderAttrs(_attrs)} data-v-46ba4a43><div class="mb-8" data-v-46ba4a43><h1 class="text-2xl font-bold text-white" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.title"))}</h1><p class="text-slate-400 mt-1" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.subtitle"))}</p></div>`);
|
|
if (unref(loading)) {
|
|
_push(`<div class="flex items-center justify-center py-20" data-v-46ba4a43><div class="text-slate-400 flex items-center gap-3" data-v-46ba4a43><svg class="w-5 h-5 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-46ba4a43><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" data-v-46ba4a43></path></svg><span data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.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" data-v-46ba4a43><p class="text-rose-400" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.load_error"))}</p><button class="mt-3 text-sm text-rose-300 hover:text-rose-200 underline" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.retry"))}</button></div>`);
|
|
} else {
|
|
_push(`<!--[--><div class="bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6" data-v-46ba4a43><div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4" data-v-46ba4a43><div data-v-46ba4a43><label class="block text-xs font-medium text-slate-400 uppercase tracking-wider mb-1.5" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.filter_user_id"))}</label><input${ssrRenderAttr("value", unref(filters).user_id)} type="number" min="1"${ssrRenderAttr("placeholder", unref(t)("gamification.ledger.user_id_placeholder"))} class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500 text-sm" data-v-46ba4a43></div><div data-v-46ba4a43><label class="block text-xs font-medium text-slate-400 uppercase tracking-wider mb-1.5" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.filter_date_from"))}</label><input${ssrRenderAttr("value", unref(filters).date_from)} type="date" class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500 text-sm" data-v-46ba4a43></div><div data-v-46ba4a43><label class="block text-xs font-medium text-slate-400 uppercase tracking-wider mb-1.5" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.filter_date_to"))}</label><input${ssrRenderAttr("value", unref(filters).date_to)} type="date" class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500 text-sm" data-v-46ba4a43></div><div data-v-46ba4a43><label class="block text-xs font-medium text-slate-400 uppercase tracking-wider mb-1.5" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.filter_reason"))}</label><input${ssrRenderAttr("value", unref(filters).reason_search)} type="text"${ssrRenderAttr("placeholder", unref(t)("gamification.ledger.reason_placeholder"))} class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500 text-sm" data-v-46ba4a43></div><div class="flex items-end gap-2" data-v-46ba4a43><button class="px-4 py-2 bg-amber-600 hover:bg-amber-500 text-white rounded-lg text-sm font-medium transition flex items-center gap-2" data-v-46ba4a43><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-46ba4a43><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" data-v-46ba4a43></path></svg> ${ssrInterpolate(unref(t)("gamification.ledger.search"))}</button><button class="px-4 py-2 bg-slate-700 hover:bg-slate-600 text-slate-300 rounded-lg text-sm font-medium transition" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.clear"))}</button><button class="px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white rounded-lg text-sm font-medium transition flex items-center gap-2 ml-auto"${ssrRenderAttr("title", unref(t)("gamification.ledger.csv_download"))} data-v-46ba4a43><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-46ba4a43><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" data-v-46ba4a43></path></svg> ${ssrInterpolate(unref(t)("gamification.ledger.csv"))}</button></div></div></div>`);
|
|
if (unref(entries).length === 0) {
|
|
_push(`<div class="bg-slate-800 rounded-xl border border-slate-700 p-12 text-center" data-v-46ba4a43><svg class="w-12 h-12 mx-auto text-slate-600 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-46ba4a43><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" data-v-46ba4a43></path></svg><p class="text-slate-400 text-sm" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.no_results"))}</p><p class="text-slate-500 text-xs mt-1" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.no_results_hint"))}</p></div>`);
|
|
} else {
|
|
_push(`<div class="bg-slate-800 rounded-xl border border-slate-700 overflow-hidden" data-v-46ba4a43><div class="overflow-x-auto" data-v-46ba4a43><table class="w-full" data-v-46ba4a43><thead data-v-46ba4a43><tr class="border-b border-slate-700" data-v-46ba4a43><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.col_id"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.col_user"))}</th><th class="text-right px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.col_points"))}</th><th class="text-right px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.col_penalty"))}</th><th class="text-right px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.col_xp"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.col_reason"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.col_source"))}</th><th class="text-left px-4 py-3 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.col_date"))}</th></tr></thead><tbody class="divide-y divide-slate-700/50" data-v-46ba4a43><!--[-->`);
|
|
ssrRenderList(unref(entries), (entry) => {
|
|
_push(`<tr class="hover:bg-slate-700/30 transition" data-v-46ba4a43><td class="px-4 py-3 text-sm text-slate-400 font-mono" data-v-46ba4a43>${ssrInterpolate(entry.id)}</td><td class="px-4 py-3" data-v-46ba4a43><div class="flex items-center gap-2" data-v-46ba4a43><span class="text-sm text-slate-300" data-v-46ba4a43>${ssrInterpolate(entry.user_name)}</span><span class="text-xs text-slate-500 font-mono" data-v-46ba4a43>#${ssrInterpolate(entry.user_id)}</span></div></td><td class="px-4 py-3 text-right" data-v-46ba4a43><span class="${ssrRenderClass([entry.points > 0 ? "text-emerald-400" : entry.points < 0 ? "text-rose-400" : "text-slate-400", "text-sm font-semibold"])}" data-v-46ba4a43>${ssrInterpolate(entry.points > 0 ? "+" : "")}${ssrInterpolate(entry.points)}</span></td><td class="px-4 py-3 text-right" data-v-46ba4a43>`);
|
|
if (entry.penalty_change) {
|
|
_push(`<span class="text-sm font-semibold text-rose-400" data-v-46ba4a43> +${ssrInterpolate(entry.penalty_change)}</span>`);
|
|
} else {
|
|
_push(`<span class="text-sm text-slate-500" data-v-46ba4a43>—</span>`);
|
|
}
|
|
_push(`</td><td class="px-4 py-3 text-right" data-v-46ba4a43>`);
|
|
if (entry.xp) {
|
|
_push(`<span class="text-sm text-cyan-400 font-mono" data-v-46ba4a43>${ssrInterpolate(entry.xp)}</span>`);
|
|
} else {
|
|
_push(`<span class="text-sm text-slate-500" data-v-46ba4a43>—</span>`);
|
|
}
|
|
_push(`</td><td class="px-4 py-3 max-w-xs" data-v-46ba4a43><p class="text-sm text-slate-300 truncate"${ssrRenderAttr("title", entry.reason)} data-v-46ba4a43>${ssrInterpolate(entry.reason)}</p></td><td class="px-4 py-3" data-v-46ba4a43>`);
|
|
if (entry.source_type) {
|
|
_push(`<div class="flex items-center gap-1.5" data-v-46ba4a43><span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-slate-700 text-slate-300" data-v-46ba4a43>${ssrInterpolate(entry.source_type)}</span>`);
|
|
if (entry.source_id) {
|
|
_push(`<span class="text-xs text-slate-500 font-mono" data-v-46ba4a43>#${ssrInterpolate(entry.source_id)}</span>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
} else {
|
|
_push(`<span class="text-sm text-slate-500" data-v-46ba4a43>—</span>`);
|
|
}
|
|
_push(`</td><td class="px-4 py-3 text-sm text-slate-400 whitespace-nowrap" data-v-46ba4a43>${ssrInterpolate(formatDate(entry.created_at))}</td></tr>`);
|
|
});
|
|
_push(`<!--]--></tbody></table></div><div class="flex items-center justify-between px-4 py-3 border-t border-slate-700" data-v-46ba4a43><p class="text-sm text-slate-400" data-v-46ba4a43>${ssrInterpolate(unref(total))} ${ssrInterpolate(unref(t)("gamification.ledger.total_results"))} ${ssrInterpolate(unref(entries).length)} ${ssrInterpolate(unref(t)("gamification.ledger.shown"))} `);
|
|
if (unref(filters).user_id || unref(filters).date_from || unref(filters).date_to || unref(filters).reason_search) {
|
|
_push(`<span class="text-slate-500" data-v-46ba4a43> (${ssrInterpolate(unref(t)("gamification.ledger.filtered"))}) </span>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</p><div class="flex items-center gap-2" data-v-46ba4a43><button${ssrIncludeBooleanAttr(unref(offset) === 0) ? " disabled" : ""} class="${ssrRenderClass([unref(offset) === 0 ? "text-slate-600" : "text-slate-300 hover:bg-slate-700 hover:text-white", "px-3 py-1.5 rounded-lg text-sm font-medium transition disabled:opacity-30 disabled:cursor-not-allowed"])}" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.prev"))}</button><span class="text-sm text-slate-400 px-2" data-v-46ba4a43>${ssrInterpolate(unref(currentPage))} / ${ssrInterpolate(unref(totalPages))}</span><button${ssrIncludeBooleanAttr(unref(offset) + unref(limit) >= unref(total)) ? " disabled" : ""} class="${ssrRenderClass([unref(offset) + unref(limit) >= unref(total) ? "text-slate-600" : "text-slate-300 hover:bg-slate-700 hover:text-white", "px-3 py-1.5 rounded-lg text-sm font-medium transition disabled:opacity-30 disabled:cursor-not-allowed"])}" data-v-46ba4a43>${ssrInterpolate(unref(t)("gamification.ledger.next"))}</button></div></div></div>`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
}
|
|
if (unref(toast)) {
|
|
_push(`<div class="fixed bottom-6 right-6 z-50 bg-emerald-600 text-white px-4 py-3 rounded-lg shadow-lg text-sm flex items-center gap-2 animate-slide-up" data-v-46ba4a43><svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-46ba4a43><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" data-v-46ba4a43></path></svg> ${ssrInterpolate(unref(toast))}</div>`);
|
|
} else {
|
|
_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/gamification/ledger.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
const ledger = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-46ba4a43"]]);
|
|
export {
|
|
ledger as default
|
|
};
|
|
//# sourceMappingURL=ledger-CkE6BXLf.js.map
|