<script setup>
const emit = defineEmits(['confirmed'])

const props = defineProps({
  color: {
    type: String,
    required:false
  },
  variant: {
    type: String,
    required:false
  },
  type: {
    type: String,
    required:false
  }

})

const {color,variant, type} = props

const dataStore = useDataStore()
const dataType = dataStore.dataTypes[type]

const showModal = ref(false)

const emitConfirm = () => {
  showModal.value = false
  emit('confirmed')
}
</script>

<template>
  <UButton
    :color="color"
    :variant="variant"
    @click="showModal = true"
  >
    Archivieren
  </UButton>
  <UModal v-model:open="showModal">
    <template #content>
      <UCard>
        <template #header>
          <span class="text-md font-bold">Archivieren bestätigen</span>
        </template>
        Möchten Sie diese/-s/-n {{dataType.labelSingle}} wirklich archivieren?

        <template #footer>
          <div class="text-right">
            <UButtonGroup>
              <UButton
                  variant="outline"
                  @click="showModal = false"
              >
                Abbrechen
              </UButton>
              <UButton
                  @click="emitConfirm"
                  class="ml-2"
                  color="error"
              >
                Archivieren
              </UButton>
            </UButtonGroup>

          </div>
        </template>
      </UCard>
    </template>
  </UModal>
</template>

<style scoped>

</style>
