76 lines
2.2 KiB
Vue
76 lines
2.2 KiB
Vue
|
<template>
|
||
|
<div class="w-full md:max-w-md">
|
||
|
<div class="flex flex-col items-center">
|
||
|
<p class="text-xl font-medium">Auszeichnung {{ award?.award }} löschen?</p>
|
||
|
</div>
|
||
|
<br />
|
||
|
|
||
|
<div class="flex flex-row gap-2">
|
||
|
<button primary :disabled="deleteStatus == 'loading' || deleteStatus?.status == 'success'" @click="triggerDelete">
|
||
|
unwiederuflich löschen
|
||
|
</button>
|
||
|
<Spinner v-if="deleteStatus == 'loading'" class="my-auto" />
|
||
|
<SuccessCheckmark v-else-if="deleteStatus?.status == 'success'" />
|
||
|
<FailureXMark v-else-if="deleteStatus?.status == 'failed'" />
|
||
|
</div>
|
||
|
|
||
|
<div class="flex flex-row justify-end">
|
||
|
<div class="flex flex-row gap-4 py-2">
|
||
|
<button primary-outline @click="closeModal" :disabled="deleteStatus != null">abbrechen</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script setup lang="ts">
|
||
|
import { defineComponent } from "vue";
|
||
|
import { mapState, mapActions } from "pinia";
|
||
|
import { useModalStore } from "@/stores/modal";
|
||
|
import Spinner from "@/components/Spinner.vue";
|
||
|
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
||
|
import FailureXMark from "@/components/FailureXMark.vue";
|
||
|
import { useRoleStore } from "@/stores/admin/role";
|
||
|
import { useAwardStore } from "@/stores/admin/award";
|
||
|
</script>
|
||
|
|
||
|
<script lang="ts">
|
||
|
export default defineComponent({
|
||
|
data() {
|
||
|
return {
|
||
|
timeout: undefined as any,
|
||
|
};
|
||
|
},
|
||
|
watch: {
|
||
|
deleteStatus() {
|
||
|
if (this.deleteStatus != "loading" && this.deleteStatus?.status == "success") {
|
||
|
this.timeout = setTimeout(() => {
|
||
|
this.closeModal();
|
||
|
}, 1500);
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
mounted() {
|
||
|
this.resetStatus();
|
||
|
},
|
||
|
beforeUnmount() {
|
||
|
try {
|
||
|
clearTimeout(this.timeout);
|
||
|
} catch (error) {}
|
||
|
},
|
||
|
computed: {
|
||
|
...mapState(useModalStore, ["data"]),
|
||
|
...mapState(useAwardStore, ["awards", "deleteStatus"]),
|
||
|
award() {
|
||
|
return this.awards.find((r) => r.id == this.data);
|
||
|
},
|
||
|
},
|
||
|
methods: {
|
||
|
...mapActions(useModalStore, ["closeModal"]),
|
||
|
...mapActions(useAwardStore, ["deleteAward", "resetStatus"]),
|
||
|
triggerDelete() {
|
||
|
this.deleteAward(this.data);
|
||
|
},
|
||
|
},
|
||
|
});
|
||
|
</script>
|