133 lines
16 KiB
JavaScript
133 lines
16 KiB
JavaScript
import { defineComponent, ref, reactive, unref, useSSRContext } from "vue";
|
|
import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderAttr, ssrRenderClass, ssrIncludeBooleanAttr, ssrLooseContain } 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: "point-rules",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const { t } = useI18n();
|
|
const loading = ref(true);
|
|
const error = ref(false);
|
|
const rules = ref([]);
|
|
const showModal = ref(false);
|
|
const showDeleteModal = ref(false);
|
|
const editingRule = ref(null);
|
|
const deletingRule = ref(null);
|
|
const saving = ref(false);
|
|
const formError = ref("");
|
|
const toast = ref("");
|
|
const editingCell = ref(null);
|
|
const editValue = ref("");
|
|
ref(null);
|
|
ref(false);
|
|
const form = reactive({
|
|
action_key: "",
|
|
points: 0,
|
|
description: "",
|
|
is_active: true
|
|
});
|
|
function isEditing(ruleId, field) {
|
|
return editingCell.value?.id === ruleId && editingCell.value?.field === field;
|
|
}
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(`<div${ssrRenderAttrs(_attrs)} data-v-f21993c6><div class="mb-8" data-v-f21993c6><h1 class="text-2xl font-bold text-white" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.title"))}</h1><p class="text-slate-400 mt-1" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.subtitle"))}</p></div>`);
|
|
if (loading.value) {
|
|
_push(`<div class="flex items-center justify-center py-20" data-v-f21993c6><div class="text-slate-400 flex items-center gap-3" data-v-f21993c6><svg class="w-5 h-5 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-f21993c6><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-f21993c6></path></svg><span data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.loading"))}</span></div></div>`);
|
|
} else if (error.value) {
|
|
_push(`<div class="bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8" data-v-f21993c6><p class="text-rose-400" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.error"))}</p><button class="mt-3 text-sm text-rose-300 hover:text-rose-200 underline" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.retry"))}</button></div>`);
|
|
} else {
|
|
_push(`<!--[--><div class="mb-6 flex justify-end" data-v-f21993c6><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" data-v-f21993c6><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-f21993c6><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" data-v-f21993c6></path></svg> ${ssrInterpolate(unref(t)("gamification.point_rules.create"))}</button></div><div class="bg-slate-800 rounded-xl border border-slate-700 overflow-hidden" data-v-f21993c6><table class="w-full" data-v-f21993c6><thead data-v-f21993c6><tr class="border-b border-slate-700" data-v-f21993c6><th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.id"))}</th><th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.action_key"))}</th><th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.points"))}</th><th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.description"))}</th><th class="text-left px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.status"))}</th><th class="text-right px-6 py-4 text-xs font-medium text-slate-400 uppercase tracking-wider" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.actions"))}</th></tr></thead><tbody class="divide-y divide-slate-700/50" data-v-f21993c6><!--[-->`);
|
|
ssrRenderList(rules.value, (rule) => {
|
|
_push(`<tr class="hover:bg-slate-700/30 transition" data-v-f21993c6><td class="px-6 py-4 text-sm text-slate-400" data-v-f21993c6>${ssrInterpolate(rule.id)}</td><td class="px-6 py-4" data-v-f21993c6>`);
|
|
if (isEditing(rule.id, "action_key")) {
|
|
_push(`<input${ssrRenderAttr("value", editValue.value)} type="text" maxlength="100" class="w-full px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50" data-v-f21993c6>`);
|
|
} else {
|
|
_push(`<code class="text-sm font-mono text-amber-300 bg-amber-500/10 px-2 py-0.5 rounded cursor-pointer hover:bg-amber-500/20 transition" data-v-f21993c6>${ssrInterpolate(rule.action_key)}</code>`);
|
|
}
|
|
_push(`</td><td class="px-6 py-4" data-v-f21993c6>`);
|
|
if (isEditing(rule.id, "points")) {
|
|
_push(`<input${ssrRenderAttr("value", editValue.value)} type="number" min="-10000" max="10000" class="w-24 px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50" data-v-f21993c6>`);
|
|
} else {
|
|
_push(`<span class="${ssrRenderClass([rule.points >= 0 ? "text-emerald-400" : "text-rose-400", "text-sm font-semibold cursor-pointer hover:opacity-80 transition"])}" data-v-f21993c6>${ssrInterpolate(rule.points >= 0 ? "+" : "")}${ssrInterpolate(rule.points)}</span>`);
|
|
}
|
|
_push(`</td><td class="px-6 py-4" data-v-f21993c6>`);
|
|
if (isEditing(rule.id, "description")) {
|
|
_push(`<input${ssrRenderAttr("value", editValue.value)} type="text" class="w-full px-2 py-1 bg-slate-700 border border-amber-500 rounded text-sm text-white focus:outline-none focus:ring-2 focus:ring-amber-500/50" data-v-f21993c6>`);
|
|
} else {
|
|
_push(`<span class="text-sm text-slate-300 max-w-xs truncate block cursor-pointer hover:text-white transition" data-v-f21993c6>${ssrInterpolate(rule.description || "—")}</span>`);
|
|
}
|
|
_push(`</td><td class="px-6 py-4" data-v-f21993c6>`);
|
|
if (isEditing(rule.id, "is_active")) {
|
|
_push(`<div class="flex items-center gap-2" data-v-f21993c6><button class="${ssrRenderClass([editValue.value ? "bg-emerald-500/20 text-emerald-400 ring-1 ring-emerald-500/50" : "bg-slate-700 text-slate-400 hover:bg-slate-600", "px-2 py-1 text-xs font-medium rounded transition"])}" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.active"))}</button><button class="${ssrRenderClass([!editValue.value ? "bg-rose-500/20 text-rose-400 ring-1 ring-rose-500/50" : "bg-slate-700 text-slate-400 hover:bg-slate-600", "px-2 py-1 text-xs font-medium rounded transition"])}" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.inactive"))}</button></div>`);
|
|
} else {
|
|
_push(`<span class="${ssrRenderClass([rule.is_active ? "bg-emerald-500/10 text-emerald-400" : "bg-slate-500/10 text-slate-400", "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium cursor-pointer hover:ring-2 hover:ring-amber-500/50 transition"])}" data-v-f21993c6>${ssrInterpolate(rule.is_active ? unref(t)("gamification.point_rules.active") : unref(t)("gamification.point_rules.inactive"))}</span>`);
|
|
}
|
|
_push(`</td><td class="px-6 py-4 text-right" data-v-f21993c6><div class="flex items-center justify-end gap-2" data-v-f21993c6><button class="p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-slate-700 transition"${ssrRenderAttr("title", unref(t)("gamification.point_rules.edit"))} data-v-f21993c6><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-f21993c6><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" data-v-f21993c6></path></svg></button><button class="p-1.5 rounded-lg text-slate-400 hover:text-rose-400 hover:bg-rose-500/10 transition"${ssrRenderAttr("title", unref(t)("gamification.point_rules.delete_title"))} data-v-f21993c6><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-f21993c6><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" data-v-f21993c6></path></svg></button></div></td></tr>`);
|
|
});
|
|
_push(`<!--]-->`);
|
|
if (rules.value.length === 0) {
|
|
_push(`<tr data-v-f21993c6><td colspan="6" class="px-6 py-12 text-center text-sm text-slate-500" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.no_items"))}</td></tr>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</tbody></table></div><!--]-->`);
|
|
}
|
|
if (showModal.value) {
|
|
_push(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" data-v-f21993c6><div class="bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-lg mx-4 shadow-2xl" data-v-f21993c6><h2 class="text-lg font-semibold text-white mb-6" data-v-f21993c6>${ssrInterpolate(editingRule.value ? unref(t)("gamification.point_rules.edit_title") : unref(t)("gamification.point_rules.create_title"))}</h2><form class="space-y-4" data-v-f21993c6><div data-v-f21993c6><label class="block text-sm font-medium text-slate-300 mb-1" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.action_key_label"))}</label><input${ssrRenderAttr("value", form.action_key)} type="text" required maxlength="100"${ssrRenderAttr("placeholder", unref(t)("gamification.point_rules.action_key_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-f21993c6></div><div data-v-f21993c6><label class="block text-sm font-medium text-slate-300 mb-1" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.points_label"))}</label><input${ssrRenderAttr("value", form.points)} type="number" required min="-10000" max="10000" placeholder="0" 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-f21993c6></div><div data-v-f21993c6><label class="block text-sm font-medium text-slate-300 mb-1" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.description_label"))}</label><textarea rows="3"${ssrRenderAttr("placeholder", unref(t)("gamification.point_rules.description_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 resize-none" data-v-f21993c6>${ssrInterpolate(form.description)}</textarea></div><div class="flex items-center gap-3" data-v-f21993c6><input${ssrIncludeBooleanAttr(Array.isArray(form.is_active) ? ssrLooseContain(form.is_active, null) : form.is_active) ? " checked" : ""} type="checkbox" id="is_active" class="w-4 h-4 rounded bg-slate-700 border-slate-600 text-amber-500 focus:ring-amber-500/50" data-v-f21993c6><label for="is_active" class="text-sm text-slate-300" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.is_active"))}</label></div>`);
|
|
if (formError.value) {
|
|
_push(`<div class="bg-rose-500/10 border border-rose-500/30 rounded-lg p-3" data-v-f21993c6><p class="text-sm text-rose-400" data-v-f21993c6>${ssrInterpolate(formError.value)}</p></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<div class="flex justify-end gap-3 pt-2" data-v-f21993c6><button type="button" class="px-4 py-2 text-sm text-slate-400 hover:text-white transition" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.cancel"))}</button><button type="submit"${ssrIncludeBooleanAttr(saving.value) ? " disabled" : ""} class="px-4 py-2 bg-amber-600 hover:bg-amber-500 disabled:bg-amber-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2" data-v-f21993c6>`);
|
|
if (saving.value) {
|
|
_push(`<svg class="w-4 h-4 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-f21993c6><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-f21993c6></path></svg>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(` ${ssrInterpolate(saving.value ? unref(t)("gamification.point_rules.saving") : unref(t)("gamification.point_rules.save"))}</button></div></form></div></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (showDeleteModal.value) {
|
|
_push(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" data-v-f21993c6><div class="bg-slate-800 rounded-xl border border-slate-700 p-6 w-full max-w-md mx-4 shadow-2xl" data-v-f21993c6><h2 class="text-lg font-semibold text-white mb-2" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.delete_title"))}</h2><p class="text-sm text-slate-400 mb-6" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.delete_confirm", { name: deletingRule.value?.action_key }))}</p><div class="flex justify-end gap-3" data-v-f21993c6><button class="px-4 py-2 text-sm text-slate-400 hover:text-white transition" data-v-f21993c6>${ssrInterpolate(unref(t)("gamification.point_rules.cancel"))}</button><button${ssrIncludeBooleanAttr(saving.value) ? " disabled" : ""} class="px-4 py-2 bg-rose-600 hover:bg-rose-500 disabled:bg-rose-600/50 text-white rounded-lg text-sm font-medium transition" data-v-f21993c6>${ssrInterpolate(saving.value ? unref(t)("gamification.point_rules.deleting") : unref(t)("gamification.point_rules.delete"))}</button></div></div></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (toast.value) {
|
|
_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-f21993c6><svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-f21993c6><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-f21993c6></path></svg> ${ssrInterpolate(toast.value)}</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/point-rules.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
const pointRules = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f21993c6"]]);
|
|
export {
|
|
pointRules as default
|
|
};
|
|
//# sourceMappingURL=point-rules-tyImSuJC.js.map
|