152 lines
16 KiB
JavaScript
152 lines
16 KiB
JavaScript
import { defineComponent, ref, reactive, unref, useSSRContext } from "vue";
|
|
import { ssrRenderAttrs, ssrInterpolate, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrRenderClass } 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 "/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: "competitions",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const { t } = useI18n();
|
|
const loading = ref(true);
|
|
const error = ref(false);
|
|
const saving = ref(false);
|
|
const showModal = ref(false);
|
|
const seasons = ref([]);
|
|
const competitions = ref([]);
|
|
const editingCompetition = ref(null);
|
|
const selectedSeasonId = ref(null);
|
|
const formError = ref("");
|
|
const rulesParseError = ref(false);
|
|
const form = reactive({
|
|
name: "",
|
|
description: "",
|
|
season_id: "",
|
|
start_date: "",
|
|
end_date: "",
|
|
status: "draft",
|
|
rulesJson: ""
|
|
});
|
|
function formatDate(dateStr) {
|
|
if (!dateStr) return "";
|
|
const d = new Date(dateStr);
|
|
return d.toLocaleDateString("hu-HU", { year: "numeric", month: "long", day: "numeric" });
|
|
}
|
|
function getStatusClass(status) {
|
|
switch (status) {
|
|
case "active":
|
|
return "bg-emerald-500/10 text-emerald-400 border border-emerald-500/30";
|
|
case "draft":
|
|
return "bg-slate-700 text-slate-400 border border-slate-600";
|
|
case "completed":
|
|
return "bg-blue-500/10 text-blue-400 border border-blue-500/30";
|
|
case "cancelled":
|
|
return "bg-rose-500/10 text-rose-400 border border-rose-500/30";
|
|
default:
|
|
return "bg-slate-700 text-slate-400 border border-slate-600";
|
|
}
|
|
}
|
|
function getStatusLabel(status) {
|
|
switch (status) {
|
|
case "active":
|
|
return t("gamification.competitions.status_active");
|
|
case "draft":
|
|
return t("gamification.competitions.status_draft");
|
|
case "completed":
|
|
return t("gamification.competitions.status_completed");
|
|
case "cancelled":
|
|
return t("gamification.competitions.status_cancelled");
|
|
default:
|
|
return status;
|
|
}
|
|
}
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(`<div${ssrRenderAttrs(_attrs)}><div class="mb-8 flex items-center justify-between"><div><h1 class="text-2xl font-bold text-white">${ssrInterpolate(unref(t)("gamification.competitions.title"))}</h1><p class="text-slate-400 mt-1">${ssrInterpolate(unref(t)("gamification.competitions.subtitle"))}</p></div><button class="flex items-center gap-2 px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition"><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="M12 4v16m8-8H4"></path></svg> ${ssrInterpolate(unref(t)("gamification.competitions.create"))}</button></div><div class="mb-6"><div class="flex items-center gap-3 flex-wrap"><label class="text-sm text-slate-400">${ssrInterpolate(unref(t)("gamification.competitions.season_filter"))}</label><select class="px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"><option${ssrRenderAttr("value", null)}${ssrIncludeBooleanAttr(Array.isArray(unref(selectedSeasonId)) ? ssrLooseContain(unref(selectedSeasonId), null) : ssrLooseEqual(unref(selectedSeasonId), null)) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.competitions.all_seasons"))}</option><!--[-->`);
|
|
ssrRenderList(unref(seasons), (s) => {
|
|
_push(`<option${ssrRenderAttr("value", s.id)}${ssrIncludeBooleanAttr(Array.isArray(unref(selectedSeasonId)) ? ssrLooseContain(unref(selectedSeasonId), s.id) : ssrLooseEqual(unref(selectedSeasonId), s.id)) ? " selected" : ""}>${ssrInterpolate(s.name)} ${ssrInterpolate(s.is_active ? unref(t)("gamification.competitions.active_badge") : "")}</option>`);
|
|
});
|
|
_push(`<!--]--></select></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.competitions.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.competitions.error"))}</p><button class="mt-2 text-sm text-rose-300 hover:text-rose-200 underline">${ssrInterpolate(unref(t)("gamification.competitions.retry"))}</button></div>`);
|
|
} else {
|
|
_push(`<!--[-->`);
|
|
if (unref(competitions).length === 0) {
|
|
_push(`<div class="bg-slate-800 rounded-xl border border-slate-700 p-12 text-center"><svg class="w-12 h-12 mx-auto text-slate-600 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 100 4 2 2 0 000-4z"></path></svg><p class="text-slate-400">${ssrInterpolate(unref(t)("gamification.competitions.no_items"))}</p><button class="mt-4 px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition">${ssrInterpolate(unref(t)("gamification.competitions.create_first"))}</button></div>`);
|
|
} else {
|
|
_push(`<div class="grid grid-cols-1 lg:grid-cols-2 gap-4"><!--[-->`);
|
|
ssrRenderList(unref(competitions), (comp) => {
|
|
_push(`<div class="bg-slate-800 rounded-xl border border-slate-700 p-6 hover:border-slate-600 transition"><div class="flex items-start justify-between mb-3"><div><h3 class="text-lg font-semibold text-white">${ssrInterpolate(comp.name)}</h3>`);
|
|
if (comp.description) {
|
|
_push(`<p class="text-sm text-slate-400 mt-1 line-clamp-2">${ssrInterpolate(comp.description)}</p>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div><span class="${ssrRenderClass([getStatusClass(comp.status), "px-2.5 py-0.5 rounded-full text-xs font-medium flex-shrink-0 ml-2"])}">${ssrInterpolate(getStatusLabel(comp.status))}</span></div><div class="space-y-2 text-sm text-slate-400 mb-4"><div class="flex items-center gap-2"><svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg><span>${ssrInterpolate(formatDate(comp.start_date))} → ${ssrInterpolate(formatDate(comp.end_date))}</span></div><div class="flex items-center gap-2"><svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"></path></svg><span>${ssrInterpolate(unref(t)("gamification.competitions.season_id_label"))} ${ssrInterpolate(comp.season_id)}</span></div></div>`);
|
|
if (comp.rules && Object.keys(comp.rules).length > 0) {
|
|
_push(`<div class="mb-4"><details class="text-sm"><summary class="text-indigo-400 cursor-pointer hover:text-indigo-300">${ssrInterpolate(unref(t)("gamification.competitions.view_rules"))}</summary><pre class="mt-2 p-3 bg-slate-900 rounded-lg text-xs text-slate-300 overflow-x-auto">${ssrInterpolate(JSON.stringify(comp.rules, null, 2))}</pre></details></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<div class="flex items-center gap-2 pt-2 border-t border-slate-700/50"><button class="flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm text-indigo-400 hover:bg-indigo-500/10 transition"><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="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"></path></svg> ${ssrInterpolate(unref(t)("gamification.competitions.edit"))}</button></div></div>`);
|
|
});
|
|
_push(`<!--]--></div>`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
}
|
|
if (unref(showModal)) {
|
|
_push(`<div class="fixed inset-0 z-50 flex items-center justify-center p-4"><div class="fixed inset-0 bg-black/60"></div><div class="relative bg-slate-800 rounded-xl border border-slate-700 w-full max-w-lg p-6 shadow-2xl max-h-[90vh] overflow-y-auto"><h2 class="text-lg font-semibold text-white mb-6">${ssrInterpolate(unref(editingCompetition) ? unref(t)("gamification.competitions.edit_title") : unref(t)("gamification.competitions.create_title"))}</h2><form class="space-y-4"><div><label class="block text-sm font-medium text-slate-300 mb-1">${ssrInterpolate(unref(t)("gamification.competitions.name"))}</label><input${ssrRenderAttr("value", unref(form).name)} type="text" required class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"${ssrRenderAttr("placeholder", unref(t)("gamification.competitions.name_placeholder"))}></div><div><label class="block text-sm font-medium text-slate-300 mb-1">${ssrInterpolate(unref(t)("gamification.competitions.description"))}</label><textarea rows="3" class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"${ssrRenderAttr("placeholder", unref(t)("gamification.competitions.desc_placeholder"))}>${ssrInterpolate(unref(form).description)}</textarea></div><div><label class="block text-sm font-medium text-slate-300 mb-1">${ssrInterpolate(unref(t)("gamification.competitions.season"))}</label><select required 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-indigo-500 focus:border-transparent"><option value="" disabled${ssrIncludeBooleanAttr(Array.isArray(unref(form).season_id) ? ssrLooseContain(unref(form).season_id, "") : ssrLooseEqual(unref(form).season_id, "")) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.competitions.select_season"))}</option><!--[-->`);
|
|
ssrRenderList(unref(seasons), (s) => {
|
|
_push(`<option${ssrRenderAttr("value", s.id)}${ssrIncludeBooleanAttr(Array.isArray(unref(form).season_id) ? ssrLooseContain(unref(form).season_id, s.id) : ssrLooseEqual(unref(form).season_id, s.id)) ? " selected" : ""}>${ssrInterpolate(s.name)} ${ssrInterpolate(s.is_active ? unref(t)("gamification.competitions.active_badge") : "")}</option>`);
|
|
});
|
|
_push(`<!--]--></select></div><div><label class="block text-sm font-medium text-slate-300 mb-1">${ssrInterpolate(unref(t)("gamification.competitions.start_date"))}</label><input${ssrRenderAttr("value", unref(form).start_date)} type="date" required 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-indigo-500 focus:border-transparent"></div><div><label class="block text-sm font-medium text-slate-300 mb-1">${ssrInterpolate(unref(t)("gamification.competitions.end_date"))}</label><input${ssrRenderAttr("value", unref(form).end_date)} type="date" required 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-indigo-500 focus:border-transparent"></div><div><label class="block text-sm font-medium text-slate-300 mb-1">${ssrInterpolate(unref(t)("gamification.competitions.status"))}</label><select 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-indigo-500 focus:border-transparent"><option value="draft"${ssrIncludeBooleanAttr(Array.isArray(unref(form).status) ? ssrLooseContain(unref(form).status, "draft") : ssrLooseEqual(unref(form).status, "draft")) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.competitions.status_draft"))}</option><option value="active"${ssrIncludeBooleanAttr(Array.isArray(unref(form).status) ? ssrLooseContain(unref(form).status, "active") : ssrLooseEqual(unref(form).status, "active")) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.competitions.status_active"))}</option><option value="completed"${ssrIncludeBooleanAttr(Array.isArray(unref(form).status) ? ssrLooseContain(unref(form).status, "completed") : ssrLooseEqual(unref(form).status, "completed")) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.competitions.status_completed"))}</option><option value="cancelled"${ssrIncludeBooleanAttr(Array.isArray(unref(form).status) ? ssrLooseContain(unref(form).status, "cancelled") : ssrLooseEqual(unref(form).status, "cancelled")) ? " selected" : ""}>${ssrInterpolate(unref(t)("gamification.competitions.status_cancelled"))}</option></select></div><div><label class="block text-sm font-medium text-slate-300 mb-1">${ssrInterpolate(unref(t)("gamification.competitions.rules"))}</label><textarea rows="5" class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-400 font-mono text-xs focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"${ssrRenderAttr("placeholder", unref(t)("gamification.competitions.rules_placeholder"))}>${ssrInterpolate(unref(form).rulesJson)}</textarea>`);
|
|
if (unref(rulesParseError)) {
|
|
_push(`<p class="text-xs text-rose-400 mt-1">${ssrInterpolate(unref(t)("gamification.competitions.invalid_json"))}</p>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
if (unref(formError)) {
|
|
_push(`<div class="bg-rose-500/10 border border-rose-500/30 rounded-lg p-3"><p class="text-sm text-rose-400">${ssrInterpolate(unref(formError))}</p></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<div class="flex items-center justify-end gap-3 pt-2"><button type="button" class="px-4 py-2 text-sm text-slate-400 hover:text-white transition">${ssrInterpolate(unref(t)("gamification.competitions.cancel"))}</button><button type="submit"${ssrIncludeBooleanAttr(unref(saving) || unref(rulesParseError)) ? " disabled" : ""} class="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 disabled:bg-indigo-600/50 text-white text-sm font-medium rounded-lg transition flex items-center gap-2">`);
|
|
if (unref(saving)) {
|
|
_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(editingCompetition) ? unref(t)("gamification.competitions.save") : unref(t)("gamification.competitions.create_btn"))}</button></div></form></div></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/competitions.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
export {
|
|
_sfc_main as default
|
|
};
|
|
//# sourceMappingURL=competitions-1WDTeHdG.js.map
|