refactor: rework ModalWarning to new requests

This commit is contained in:
axolotle 2024-08-05 17:14:51 +02:00
parent f0bd35e2b1
commit 519de69d29

View file

@ -1,40 +1,27 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import { useStore } from 'vuex'
import type { Obj } from '@/types/commons' import ModalOverlay from '@/components/modals/ModalOverlay.vue'
import type { APIRequest } from '@/composables/useRequests'
const props = defineProps<{ const props = defineProps<{
request: Obj request: APIRequest
}>() }>()
const store = useStore() // FIXME probably doesn't need a computed here
const warningMessage = computed(() => {
const warning = computed(() => { const messages = props.request.action!.messages
const messages = props.request.messages
return messages[messages.length - 1] return messages[messages.length - 1]
}) })
function dismiss() {
store.dispatch('DISMISS_WARNING', props.request)
}
</script> </script>
<template> <template>
<!-- This card receives style from `ViewLockOverlay` if used inside it --> <ModalOverlay
<div> :request="request"
<BCardBody body-class="alert alert-warning"> footer-variant="warning"
<div v-html="warning.text" /> body-variant="warning"
</BCardBody> :hide-footer="false"
>
<BCardFooter footer-bg-variant="warning"> <div v-html="warningMessage.text" />
<BButton variant="light" size="sm" v-t="'ok'" @click="dismiss" /> </ModalOverlay>
</BCardFooter>
</div>
</template> </template>
<style lang="scss" scoped>
.card-body {
padding-bottom: 1.5rem !important;
margin-bottom: 0;
}
</style>