| 1 | <template> |
| 2 | <BaseDialog |
| 3 | v-model="visible" |
| 4 | :title="title" |
| 5 | width="400px" |
| 6 | :close-on-click-modal="false" |
| 7 | :append-to-body="true" |
| 8 | :is-mobile="isMobile" |
| 9 | > |
| 10 | <p class="confirm-message">{{ message }}</p> |
| 11 | <template #footer> |
| 12 | <div class="dialog-footer"> |
| 13 | <ActionButton variant="outline" @click="handleCancel"> |
| 14 | {{ cancelText }} |
| 15 | </ActionButton> |
| 16 | <ActionButton |
| 17 | :danger="danger" |
| 18 | :loading="loading" |
| 19 | @click="handleConfirm" |
| 20 | > |
| 21 | {{ confirmText }} |
| 22 | </ActionButton> |
| 23 | </div> |
| 24 | </template> |
| 25 | </BaseDialog> |
| 26 | </template> |
| 27 | |
| 28 | <script setup lang="ts"> |
| 29 | import { computed } from 'vue' |
| 30 | import BaseDialog from './BaseDialog.vue' |
| 31 | import ActionButton from '@shared/components/ActionButton.vue' |
| 32 | |
| 33 | const props = withDefaults( |
| 34 | defineProps<{ |
| 35 | modelValue: boolean |
| 36 | title: string |
| 37 | message: string |
| 38 | confirmText?: string |
| 39 | cancelText?: string |
| 40 | danger?: boolean |
| 41 | loading?: boolean |
| 42 | isMobile?: boolean |
| 43 | }>(), |
| 44 | { |
| 45 | confirmText: 'Confirm', |
| 46 | cancelText: 'Cancel', |
| 47 | danger: false, |
| 48 | loading: false, |
| 49 | isMobile: false, |
| 50 | }, |
| 51 | ) |
| 52 | |
| 53 | const emit = defineEmits<{ |
| 54 | (e: 'update:modelValue', value: boolean): void |
| 55 | (e: 'confirm'): void |
| 56 | (e: 'cancel'): void |
| 57 | }>() |
| 58 | |
| 59 | const visible = computed({ |
| 60 | get: () => props.modelValue, |
| 61 | set: (value) => emit('update:modelValue', value), |
| 62 | }) |
| 63 | |
| 64 | const handleConfirm = () => { |
| 65 | emit('confirm') |
| 66 | } |
| 67 | |
| 68 | const handleCancel = () => { |
| 69 | visible.value = false |
| 70 | emit('cancel') |
| 71 | } |
| 72 | </script> |
| 73 | |
| 74 | <style scoped lang="scss"> |
| 75 | .confirm-message { |
| 76 | margin: 0; |
| 77 | font-size: $font-size-md; |
| 78 | color: $color-text-secondary; |
| 79 | line-height: 1.6; |
| 80 | } |
| 81 | |
| 82 | .dialog-footer { |
| 83 | display: flex; |
| 84 | justify-content: flex-end; |
| 85 | gap: $spacing-md; |
| 86 | } |
| 87 | </style> |