<template>
  <div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
    <div v-if="activeNewsletterObj != null" class="flex flex-col gap-2 w-full">
      <div class="w-full">
        <label for="title">Überschrift</label>
        <QuillEditor
          id="summary"
          theme="snow"
          placeholder="Überschrift des Newsletters..."
          style="height: 150px; max-height: 150px; min-height: 150px"
          contentType="html"
          :toolbar="toolbarOptions"
          v-model:content="activeNewsletterObj.newsletterTitle"
          :enable="can('create', 'club', 'newsletter')"
          :style="!can('create', 'club', 'newsletter') ? 'opacity: 75%; background: rgb(243 244 246)' : ''"
        />
      </div>
      <div class="flex flex-col h-1/2">
        <label for="summary">Text</label>
        <QuillEditor
          id="summary"
          theme="snow"
          placeholder="Text zum Newsletter..."
          style="height: 150px; max-height: 150px; min-height: 150px"
          contentType="html"
          :toolbar="toolbarOptions"
          v-model:content="activeNewsletterObj.newsletterText"
          :enable="can('create', 'club', 'newsletter')"
          :style="!can('create', 'club', 'newsletter') ? 'opacity: 75%; background: rgb(243 244 246)' : ''"
        />
      </div>
      <div class="flex flex-col h-1/2">
        <label for="summary">Signatur</label>
        <QuillEditor
          id="summary"
          theme="snow"
          placeholder="Zusammenfassung zum Newsletter..."
          style="height: 150px; max-height: 150px; min-height: 150px"
          contentType="html"
          :toolbar="toolbarOptions"
          v-model:content="activeNewsletterObj.newsletterSignatur"
          :enable="can('create', 'club', 'newsletter')"
          :style="!can('create', 'club', 'newsletter') ? 'opacity: 75%; background: rgb(243 244 246)' : ''"
        />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineComponent } from "vue";
import { mapActions, mapState, mapWritableState } from "pinia";
import Spinner from "@/components/Spinner.vue";
import { useNewsletterStore } from "@/stores/admin/newsletter";
import { QuillEditor } from "@vueup/vue-quill";
import "@vueup/vue-quill/dist/vue-quill.snow.css";
import { toolbarOptions } from "@/helpers/quillConfig";
import { useAbilityStore } from "@/stores/ability";
</script>

<script lang="ts">
export default defineComponent({
  props: {
    newsletterId: String,
  },
  computed: {
    ...mapWritableState(useNewsletterStore, ["loadingActive", "activeNewsletterObj"]),
    ...mapState(useAbilityStore, ["can"]),
  },
});
</script>
