2023-01-07 08:55:01 +00:00
|
|
|
<script setup lang="ts">
|
2024-03-09 09:52:41 +00:00
|
|
|
import type { ConfirmDialogChoice, ConfirmDialogOptions } from '~/types'
|
|
|
|
import DurationPicker from '~/components/modal/DurationPicker.vue'
|
2023-01-07 08:55:01 +00:00
|
|
|
|
2024-03-09 09:52:41 +00:00
|
|
|
const props = defineProps<ConfirmDialogOptions>()
|
2023-01-07 08:55:01 +00:00
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(evt: 'choice', choice: ConfirmDialogChoice): void
|
|
|
|
}>()
|
2024-03-09 09:52:41 +00:00
|
|
|
|
|
|
|
const hasDuration = ref(false)
|
|
|
|
const isValidDuration = ref(true)
|
|
|
|
const duration = ref(60 * 60) // default to 1 hour
|
|
|
|
const shouldMuteNotifications = ref(true)
|
|
|
|
const isMute = computed(() => props.extraOptionType === 'mute')
|
|
|
|
|
|
|
|
function handleChoice(choice: ConfirmDialogChoice['choice']) {
|
|
|
|
const dialogChoice = {
|
|
|
|
choice,
|
|
|
|
...isMute && {
|
|
|
|
extraOptions: {
|
|
|
|
mute: {
|
|
|
|
duration: hasDuration.value ? duration.value : 0,
|
|
|
|
notifications: shouldMuteNotifications.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
emit('choice', dialogChoice)
|
|
|
|
}
|
2023-01-07 08:55:01 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div flex="~ col" gap-6>
|
2024-01-09 19:51:36 +00:00
|
|
|
<div font-bold text-lg>
|
2023-01-07 08:55:01 +00:00
|
|
|
{{ title }}
|
|
|
|
</div>
|
|
|
|
<div v-if="description">
|
|
|
|
{{ description }}
|
|
|
|
</div>
|
2024-03-09 09:52:41 +00:00
|
|
|
<div v-if="isMute" flex-col flex gap-4>
|
|
|
|
<CommonCheckbox v-model="hasDuration" :label="$t('confirm.mute_account.specify_duration')" prepend-checkbox checked-icon-color="text-primary" />
|
|
|
|
<DurationPicker v-if="hasDuration" v-model="duration" v-model:is-valid="isValidDuration" />
|
|
|
|
<CommonCheckbox v-model="shouldMuteNotifications" :label="$t('confirm.mute_account.notifications')" prepend-checkbox checked-icon-color="text-primary" />
|
|
|
|
</div>
|
|
|
|
|
2023-01-07 08:55:01 +00:00
|
|
|
<div flex justify-end gap-2>
|
2024-03-09 09:52:41 +00:00
|
|
|
<button btn-text @click="handleChoice('cancel')">
|
2023-01-16 08:56:36 +00:00
|
|
|
{{ cancel || $t('confirm.common.cancel') }}
|
2023-01-07 08:55:01 +00:00
|
|
|
</button>
|
2024-03-09 09:52:41 +00:00
|
|
|
<button btn-solid :disabled="!isValidDuration" @click="handleChoice('confirm')">
|
2023-01-16 08:56:36 +00:00
|
|
|
{{ confirm || $t('confirm.common.confirm') }}
|
2023-01-07 08:55:01 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|