2024-12-26 13:57:45 +01:00
|
|
|
<template>
|
2024-12-28 18:03:20 +01:00
|
|
|
<div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
|
2024-12-26 13:57:45 +01:00
|
|
|
<Spinner v-if="loading == 'loading'" class="mx-auto" />
|
2024-12-28 18:03:20 +01:00
|
|
|
<p v-else-if="loading == 'failed'" @click="fetchNewsletterPrintout" class="cursor-pointer">
|
2024-12-26 13:57:45 +01:00
|
|
|
↺ laden fehlgeschlagen
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<div class="flex flex-col gap-2 h-full overflow-y-auto">
|
2024-12-28 18:03:20 +01:00
|
|
|
<div v-for="print in printout" :key="print" class="flex flex-col h-fit w-full border border-primary rounded-md">
|
2024-12-26 13:57:45 +01:00
|
|
|
<div class="bg-primary p-2 text-white flex flex-row justify-between items-center">
|
2024-12-28 18:03:20 +01:00
|
|
|
<p>{{ print }}</p>
|
2024-12-26 13:57:45 +01:00
|
|
|
<div class="flex flex-row">
|
2024-12-30 14:46:39 +01:00
|
|
|
<div v-if="print.endsWith('.pdf')">
|
2024-12-28 18:03:20 +01:00
|
|
|
<ViewfinderCircleIcon class="w-5 h-5 p-1 box-content cursor-pointer" @click="openPdfShow(print)" />
|
2024-12-26 13:57:45 +01:00
|
|
|
</div>
|
|
|
|
<div>
|
2024-12-28 18:03:20 +01:00
|
|
|
<ArrowDownTrayIcon class="w-5 h-5 p-1 box-content cursor-pointer" @click="downloadPdf(print)" />
|
2024-12-26 13:57:45 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-12-28 18:03:20 +01:00
|
|
|
<div class="flex flex-row flex-wrap justify-start gap-2">
|
2024-12-26 13:57:45 +01:00
|
|
|
<button
|
|
|
|
v-if="can('create', 'club', 'newsletter')"
|
|
|
|
primary
|
2024-12-30 14:46:39 +01:00
|
|
|
class="!w-fit whitespace-nowrap flex flex-row gap-2"
|
2024-12-26 13:57:45 +01:00
|
|
|
:disabled="printing != undefined"
|
2024-12-28 18:03:20 +01:00
|
|
|
@click="createNewsletterPrintout"
|
2024-12-26 13:57:45 +01:00
|
|
|
>
|
2024-12-28 18:03:20 +01:00
|
|
|
Newsletter drucken
|
|
|
|
<Spinner v-if="printing == 'loading'" class="my-auto" />
|
|
|
|
<SuccessCheckmark v-else-if="printing == 'success'" />
|
|
|
|
<FailureXMark v-else-if="printing == 'failed'" />
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
v-if="can('create', 'club', 'newsletter')"
|
|
|
|
primary
|
2024-12-30 14:46:39 +01:00
|
|
|
class="!w-fit whitespace-nowrap flex flex-row gap-2"
|
2024-12-28 18:03:20 +01:00
|
|
|
:disabled="sending != undefined"
|
|
|
|
@click="createNewsletterSend"
|
|
|
|
>
|
|
|
|
Mails versenden
|
|
|
|
<Spinner v-if="sending == 'loading'" class="my-auto" />
|
|
|
|
<SuccessCheckmark v-else-if="sending == 'success'" />
|
|
|
|
<FailureXMark v-else-if="sending == 'failed'" />
|
|
|
|
</button>
|
|
|
|
<button v-if="can('create', 'club', 'newsletter')" primary-outline class="!w-fit" @click="openPdfShow()">
|
|
|
|
Newsletter Vorschau
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
v-if="can('create', 'club', 'newsletter')"
|
|
|
|
primary-outline
|
2024-12-30 14:46:39 +01:00
|
|
|
class="!w-fit whitespace-nowrap flex flex-row gap-2"
|
2024-12-28 18:03:20 +01:00
|
|
|
:disabled="sendingPreview != undefined"
|
|
|
|
@click="createNewsletterMailPreview"
|
|
|
|
>
|
|
|
|
Mail Vorschau
|
|
|
|
<Spinner v-if="sendingPreview == 'loading'" class="my-auto" />
|
|
|
|
<SuccessCheckmark v-else-if="sendingPreview == 'success'" />
|
|
|
|
<FailureXMark v-else-if="sendingPreview == 'failed'" />
|
2024-12-26 13:57:45 +01:00
|
|
|
</button>
|
|
|
|
</div>
|
2024-12-28 18:03:20 +01:00
|
|
|
</div>
|
2024-12-26 13:57:45 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
|
|
|
|
import { mapActions, mapState } from "pinia";
|
|
|
|
import Spinner from "@/components/Spinner.vue";
|
|
|
|
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
|
|
|
import FailureXMark from "@/components/FailureXMark.vue";
|
2024-12-28 18:03:20 +01:00
|
|
|
// import { useNewsletterPrintoutStore } from "@/stores/admin/newsletterPrintout";
|
2024-12-26 13:57:45 +01:00
|
|
|
import { ArrowDownTrayIcon, ViewfinderCircleIcon } from "@heroicons/vue/24/outline";
|
|
|
|
import { useModalStore } from "@/stores/modal";
|
|
|
|
import { useAbilityStore } from "@/stores/ability";
|
2025-01-02 18:28:13 +01:00
|
|
|
import { useNewsletterPrintoutStore } from "../../../../stores/admin/club/newsletter/newsletterPrintout";
|
2024-12-26 13:57:45 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
newsletterId: String,
|
|
|
|
},
|
2024-12-28 18:03:20 +01:00
|
|
|
computed: {
|
|
|
|
...mapState(useNewsletterPrintoutStore, ["printout", "loading", "printing", "sending", "sendingPreview"]),
|
|
|
|
...mapState(useAbilityStore, ["can"]),
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.fetchNewsletterPrintout();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(useModalStore, ["openModal"]),
|
|
|
|
...mapActions(useNewsletterPrintoutStore, [
|
|
|
|
"fetchNewsletterPrintout",
|
|
|
|
"createNewsletterPrintout",
|
|
|
|
"fetchNewsletterPrintoutById",
|
|
|
|
"createNewsletterMailPreview",
|
|
|
|
"createNewsletterSend",
|
|
|
|
]),
|
|
|
|
openPdfShow(filename?: string) {
|
|
|
|
this.openModal(
|
|
|
|
markRaw(defineAsyncComponent(() => import("@/components/admin/club/newsletter/NewsletterPreviewModal.vue"))),
|
|
|
|
filename
|
|
|
|
);
|
|
|
|
},
|
|
|
|
downloadPdf(filename: string) {
|
|
|
|
this.fetchNewsletterPrintoutById(filename)
|
|
|
|
.then((response) => {
|
|
|
|
const fileURL = window.URL.createObjectURL(new Blob([response.data]));
|
|
|
|
const fileLink = document.createElement("a");
|
|
|
|
fileLink.href = fileURL;
|
2024-12-30 14:46:39 +01:00
|
|
|
fileLink.setAttribute("download", filename);
|
2024-12-28 18:03:20 +01:00
|
|
|
document.body.appendChild(fileLink);
|
|
|
|
fileLink.click();
|
|
|
|
fileLink.remove();
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
|
|
|
},
|
|
|
|
},
|
2024-12-26 13:57:45 +01:00
|
|
|
});
|
|
|
|
</script>
|