Files
harheimertc/.output/server/chunks/build/news-C8krCg9b.mjs
2025-10-21 15:36:35 +02:00

185 lines
9.5 KiB
JavaScript

import { ref, computed, mergeProps, unref, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderComponent, ssrRenderList, ssrInterpolate, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain } from 'vue/server-renderer';
import { Plus, Loader2, Globe, User, Calendar, Edit, Trash2, Newspaper, AlertCircle } from 'lucide-vue-next';
import { u as useAuthStore } from './server.mjs';
import { u as useHead } from './composables-CK-Mp9jS.mjs';
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 'node:url';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import 'pinia';
import 'vue-router';
const _sfc_main = {
__name: "news",
__ssrInlineRender: true,
setup(__props) {
const authStore = useAuthStore();
const isLoading = ref(true);
const isSaving = ref(false);
const news = ref([]);
const showModal = ref(false);
const editingNews = ref(null);
const errorMessage = ref("");
const formData = ref({
title: "",
content: "",
isPublic: false
});
const canWrite = computed(() => {
return authStore.role === "admin" || authStore.role === "vorstand";
});
const formatDate = (dateString) => {
if (!dateString) return "";
const date = new Date(dateString);
return date.toLocaleDateString("de-DE", {
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit"
});
};
useHead({
title: "Interne News - Harheimer TC"
});
return (_ctx, _push, _parent, _attrs) => {
_push(`<div${ssrRenderAttrs(mergeProps({ class: "min-h-full py-16 bg-gray-50" }, _attrs))}><div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8"><div class="flex justify-between items-center mb-6"><div><h1 class="text-4xl sm:text-5xl font-display font-bold text-gray-900 mb-2"> Interne News </h1><div class="w-24 h-1 bg-primary-600 mb-4"></div></div>`);
if (canWrite.value) {
_push(`<button class="flex items-center px-4 py-2 bg-primary-600 hover:bg-primary-700 text-white font-semibold rounded-lg transition-colors">`);
_push(ssrRenderComponent(unref(Plus), {
size: 20,
class: "mr-2"
}, null, _parent));
_push(` News erstellen </button>`);
} else {
_push(`<!---->`);
}
_push(`</div>`);
if (isLoading.value) {
_push(`<div class="flex items-center justify-center py-12">`);
_push(ssrRenderComponent(unref(Loader2), {
size: 40,
class: "animate-spin text-primary-600"
}, null, _parent));
_push(`</div>`);
} else {
_push(`<div class="space-y-6"><!--[-->`);
ssrRenderList(news.value, (item) => {
_push(`<article class="bg-white rounded-xl shadow-lg p-6 border border-gray-100"><div class="flex justify-between items-start mb-4"><div class="flex-1"><div class="flex items-center space-x-3 mb-2"><h2 class="text-2xl font-display font-bold text-gray-900">${ssrInterpolate(item.title)}</h2>`);
if (item.isPublic) {
_push(`<span class="px-3 py-1 bg-blue-100 text-blue-800 text-xs font-semibold rounded-full flex items-center">`);
_push(ssrRenderComponent(unref(Globe), {
size: 14,
class: "mr-1"
}, null, _parent));
_push(` Öffentlich </span>`);
} else {
_push(`<!---->`);
}
_push(`</div><div class="flex items-center text-sm text-gray-500 space-x-4"><div class="flex items-center">`);
_push(ssrRenderComponent(unref(User), {
size: 16,
class: "mr-1"
}, null, _parent));
_push(` ${ssrInterpolate(item.author)}</div><div class="flex items-center">`);
_push(ssrRenderComponent(unref(Calendar), {
size: 16,
class: "mr-1"
}, null, _parent));
_push(` ${ssrInterpolate(formatDate(item.created))}</div>`);
if (item.updated !== item.created) {
_push(`<div class="flex items-center">`);
_push(ssrRenderComponent(unref(Edit), {
size: 16,
class: "mr-1"
}, null, _parent));
_push(` Aktualisiert: ${ssrInterpolate(formatDate(item.updated))}</div>`);
} else {
_push(`<!---->`);
}
_push(`</div></div>`);
if (canWrite.value) {
_push(`<div class="flex space-x-2 ml-4"><button class="p-2 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors" title="Bearbeiten">`);
_push(ssrRenderComponent(unref(Edit), { size: 20 }, null, _parent));
_push(`</button><button class="p-2 text-red-600 hover:bg-red-50 rounded-lg transition-colors" title="Löschen">`);
_push(ssrRenderComponent(unref(Trash2), { size: 20 }, null, _parent));
_push(`</button></div>`);
} else {
_push(`<!---->`);
}
_push(`</div><div class="prose prose-lg max-w-none text-gray-700 whitespace-pre-wrap">${ssrInterpolate(item.content)}</div></article>`);
});
_push(`<!--]-->`);
if (news.value.length === 0) {
_push(`<div class="text-center py-12">`);
_push(ssrRenderComponent(unref(Newspaper), {
size: 48,
class: "mx-auto text-gray-400 mb-4"
}, null, _parent));
_push(`<p class="text-gray-500 text-lg">Noch keine internen News vorhanden.</p>`);
if (canWrite.value) {
_push(`<p class="text-gray-400 text-sm mt-2"> Klicken Sie auf &quot;News erstellen&quot;, um die erste News zu veröffentlichen. </p>`);
} else {
_push(`<!---->`);
}
_push(`</div>`);
} else {
_push(`<!---->`);
}
_push(`</div>`);
}
if (showModal.value) {
_push(`<div class="fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4"><div class="bg-white rounded-xl shadow-2xl max-w-3xl w-full p-8 max-h-[90vh] overflow-y-auto"><h2 class="text-2xl font-display font-bold text-gray-900 mb-6">${ssrInterpolate(editingNews.value ? "News bearbeiten" : "News erstellen")}</h2><form class="space-y-4"><div><label class="block text-sm font-medium text-gray-700 mb-2">Titel *</label><input${ssrRenderAttr("value", formData.value.title)} type="text" required class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"${ssrIncludeBooleanAttr(isSaving.value) ? " disabled" : ""}></div><div><label class="block text-sm font-medium text-gray-700 mb-2">Inhalt *</label><textarea rows="12" required class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"${ssrIncludeBooleanAttr(isSaving.value) ? " disabled" : ""}>${ssrInterpolate(formData.value.content)}</textarea></div><div class="flex items-center space-x-3 p-4 bg-blue-50 rounded-lg border border-blue-200"><input id="isPublic"${ssrIncludeBooleanAttr(Array.isArray(formData.value.isPublic) ? ssrLooseContain(formData.value.isPublic, null) : formData.value.isPublic) ? " checked" : ""} type="checkbox" class="w-5 h-5 text-primary-600 border-gray-300 rounded focus:ring-primary-500"${ssrIncludeBooleanAttr(isSaving.value) ? " disabled" : ""}><label for="isPublic" class="text-sm font-medium text-gray-900 cursor-pointer flex-1"><div class="flex items-center">`);
_push(ssrRenderComponent(unref(Globe), {
size: 18,
class: "mr-2 text-blue-600"
}, null, _parent));
_push(`<span>Öffentliche News (auf Startseite anzeigen)</span></div><p class="text-xs text-gray-600 mt-1 ml-6"> Wenn aktiviert, wird diese News auch für nicht angemeldete Besucher auf der Startseite sichtbar. </p></label></div>`);
if (errorMessage.value) {
_push(`<div class="flex items-center p-3 rounded-md bg-red-50 text-red-700 text-sm">`);
_push(ssrRenderComponent(unref(AlertCircle), {
size: 20,
class: "mr-2"
}, null, _parent));
_push(` ${ssrInterpolate(errorMessage.value)}</div>`);
} else {
_push(`<!---->`);
}
_push(`<div class="flex justify-end space-x-4 pt-4"><button type="button" class="px-6 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors"${ssrIncludeBooleanAttr(isSaving.value) ? " disabled" : ""}> Abbrechen </button><button type="submit" class="px-6 py-2 bg-primary-600 hover:bg-primary-700 text-white font-semibold rounded-lg transition-colors flex items-center"${ssrIncludeBooleanAttr(isSaving.value) ? " disabled" : ""}>`);
if (isSaving.value) {
_push(ssrRenderComponent(unref(Loader2), {
size: 20,
class: "animate-spin mr-2"
}, null, _parent));
} else {
_push(`<!---->`);
}
_push(`<span>${ssrInterpolate(isSaving.value ? "Speichert..." : "Speichern")}</span></button></div></form></div></div>`);
} else {
_push(`<!---->`);
}
_push(`</div></div>`);
};
}
};
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/mitgliederbereich/news.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
export { _sfc_main as default };
//# sourceMappingURL=news-C8krCg9b.mjs.map