115 lines
12 KiB
JavaScript
115 lines
12 KiB
JavaScript
import { defineComponent, ref, reactive, unref, useSSRContext } from "vue";
|
|
import { ssrRenderAttrs, ssrInterpolate, ssrRenderList, ssrRenderClass, ssrRenderAttr, 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 "/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: "seasons",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const { t } = useI18n();
|
|
const loading = ref(true);
|
|
const error = ref(false);
|
|
const saving = ref(false);
|
|
const showModal = ref(false);
|
|
const showActivateModal = ref(false);
|
|
const seasons = ref([]);
|
|
const editingSeason = ref(null);
|
|
const activatingSeason = ref(null);
|
|
const formError = ref("");
|
|
const form = reactive({
|
|
name: "",
|
|
start_date: "",
|
|
end_date: "",
|
|
is_active: false
|
|
});
|
|
function formatDate(dateStr) {
|
|
if (!dateStr) return "";
|
|
const d = new Date(dateStr);
|
|
return d.toLocaleDateString("hu-HU", { year: "numeric", month: "long", day: "numeric" });
|
|
}
|
|
function formatDateTime(dateStr) {
|
|
if (!dateStr) return "";
|
|
const d = new Date(dateStr);
|
|
return d.toLocaleDateString("hu-HU", { year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" });
|
|
}
|
|
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.seasons.title"))}</h1><p class="text-slate-400 mt-1">${ssrInterpolate(unref(t)("gamification.seasons.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.seasons.create_btn"))}</button></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.seasons.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.seasons.load_error"))}</p><button class="mt-2 text-sm text-rose-300 hover:text-rose-200 underline">${ssrInterpolate(unref(t)("gamification.seasons.retry"))}</button></div>`);
|
|
} else {
|
|
_push(`<!--[-->`);
|
|
if (unref(seasons).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="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><p class="text-slate-400">${ssrInterpolate(unref(t)("gamification.seasons.empty"))}</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.seasons.create_first"))}</button></div>`);
|
|
} else {
|
|
_push(`<div class="space-y-4"><!--[-->`);
|
|
ssrRenderList(unref(seasons), (season) => {
|
|
_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"><div class="flex-1"><div class="flex items-center gap-3 mb-2"><h3 class="text-lg font-semibold text-white">${ssrInterpolate(season.name)}</h3><span class="${ssrRenderClass([season.is_active ? "bg-emerald-500/10 text-emerald-400 border border-emerald-500/30" : "bg-slate-700 text-slate-400 border border-slate-600", "px-2.5 py-0.5 rounded-full text-xs font-medium"])}">${ssrInterpolate(season.is_active ? unref(t)("gamification.seasons.active") : unref(t)("gamification.seasons.inactive"))}</span></div><div class="flex items-center gap-6 text-sm text-slate-400"><div class="flex items-center gap-2"><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="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(season.start_date))} → ${ssrInterpolate(formatDate(season.end_date))}</span></div><div class="flex items-center gap-2"><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 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg><span>${ssrInterpolate(unref(t)("gamification.seasons.created_at"))} ${ssrInterpolate(formatDateTime(season.created_at))}</span></div></div></div><div class="flex items-center gap-2 ml-4">`);
|
|
if (!season.is_active) {
|
|
_push(`<button class="p-2 rounded-lg text-emerald-400 hover:bg-emerald-500/10 transition"${ssrRenderAttr("title", unref(t)("gamification.seasons.activate"))}><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg></button>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<button class="p-2 rounded-lg text-indigo-400 hover:bg-indigo-500/10 transition"${ssrRenderAttr("title", unref(t)("gamification.seasons.edit"))}><svg class="w-5 h-5" 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></button></div></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"><h2 class="text-lg font-semibold text-white mb-6">${ssrInterpolate(unref(editingSeason) ? unref(t)("gamification.seasons.edit_title") : unref(t)("gamification.seasons.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.seasons.name_label"))}</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.seasons.name_placeholder"))}></div><div><label class="block text-sm font-medium text-slate-300 mb-1">${ssrInterpolate(unref(t)("gamification.seasons.start_date_label"))}</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.seasons.end_date_label"))}</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>`);
|
|
if (!unref(editingSeason)) {
|
|
_push(`<div class="flex items-center gap-3"><input${ssrIncludeBooleanAttr(Array.isArray(unref(form).is_active) ? ssrLooseContain(unref(form).is_active, null) : unref(form).is_active) ? " checked" : ""} type="checkbox" id="is_active" class="w-4 h-4 rounded border-slate-600 bg-slate-700 text-indigo-600 focus:ring-indigo-500"><label for="is_active" class="text-sm text-slate-300">${ssrInterpolate(unref(t)("gamification.seasons.active_on_create"))}</label></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
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.seasons.cancel"))}</button><button type="submit"${ssrIncludeBooleanAttr(unref(saving)) ? " 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(editingSeason) ? unref(t)("gamification.seasons.save") : unref(t)("gamification.seasons.create"))}</button></div></form></div></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (unref(showActivateModal)) {
|
|
_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-md p-6 shadow-2xl"><h2 class="text-lg font-semibold text-white mb-2">${ssrInterpolate(unref(t)("gamification.seasons.activate_title"))}</h2><p class="text-slate-400 text-sm mb-6">${ssrInterpolate(unref(t)("gamification.seasons.activate_confirm", { name: unref(activatingSeason)?.name }))}</p><div class="flex items-center justify-end gap-3"><button class="px-4 py-2 text-sm text-slate-400 hover:text-white transition">${ssrInterpolate(unref(t)("gamification.seasons.cancel"))}</button><button${ssrIncludeBooleanAttr(unref(saving)) ? " disabled" : ""} class="px-4 py-2 bg-emerald-600 hover:bg-emerald-500 disabled:bg-emerald-600/50 text-white text-sm font-medium rounded-lg transition">${ssrInterpolate(unref(saving) ? unref(t)("gamification.seasons.activating") : unref(t)("gamification.seasons.activate"))}</button></div></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/seasons.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
export {
|
|
_sfc_main as default
|
|
};
|
|
//# sourceMappingURL=seasons-B_EJxQ8K.js.map
|