2023-01-07 11:55:01 +03:00
|
|
|
<script setup lang="ts">
|
2024-03-09 12:52:41 +03:00
|
|
|
import type { ConfirmDialogChoice, ConfirmDialogOptions } from '~/types'
|
|
|
|
import DurationPicker from '~/components/modal/DurationPicker.vue'
|
2023-01-07 11:55:01 +03:00
|
|
|
|
2024-03-09 12:52:41 +03:00
|
|
|
const props = defineProps<ConfirmDialogOptions>()
|
2023-01-07 11:55:01 +03:00
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(evt: 'choice', choice: ConfirmDialogChoice): void
|
|
|
|
}>()
|
2024-03-09 12:52:41 +03: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,
|
2024-03-11 13:53:25 +03:00
|
|
|
...isMute.value && {
|
2024-03-09 12:52:41 +03:00
|
|
|
extraOptions: {
|
|
|
|
mute: {
|
|
|
|
duration: hasDuration.value ? duration.value : 0,
|
|
|
|
notifications: shouldMuteNotifications.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
emit('choice', dialogChoice)
|
|
|
|
}
|
2023-01-07 11:55:01 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div flex="~ col" gap-6>
|
2024-01-09 22:51:36 +03:00
|
|
|
<div font-bold text-lg>
|
2023-01-07 11:55:01 +03:00
|
|
|
{{ title }}
|
|
|
|
</div>
|
|
|
|
<div v-if="description">
|
|
|
|
{{ description }}
|
|
|
|
</div>
|
2024-03-09 12:52:41 +03: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 11:55:01 +03:00
|
|
|
<div flex justify-end gap-2>
|
2024-03-09 12:52:41 +03:00
|
|
|
<button btn-text @click="handleChoice('cancel')">
|
2023-01-16 11:56:36 +03:00
|
|
|
{{ cancel || $t('confirm.common.cancel') }}
|
2023-01-07 11:55:01 +03:00
|
|
|
</button>
|
2024-03-09 12:52:41 +03:00
|
|
|
<button btn-solid :disabled="!isValidDuration" @click="handleChoice('confirm')">
|
2023-01-16 11:56:36 +03:00
|
|
|
{{ confirm || $t('confirm.common.confirm') }}
|
2023-01-07 11:55:01 +03:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|