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