@@ -26,27 +26,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { type QRCodeDocument } from '@/types/DBDocumentTypes'
|
import { type QRCodeDocument } from '@/types/DBDocumentTypes'
|
||||||
|
import { deliveryOptions } from '@/constants/deliveryOptions'
|
||||||
|
|
||||||
const emit = defineEmits(['nextStep'])
|
const emit = defineEmits(['nextStep'])
|
||||||
const model = defineModel<QRCodeDocument['messageDeliveryMethod']>()
|
const model = defineModel<QRCodeDocument['messageDeliveryMethod']>()
|
||||||
|
|
||||||
type DeliveryOption = {
|
|
||||||
label: string
|
|
||||||
method: QRCodeDocument['messageDeliveryMethod']
|
|
||||||
}
|
|
||||||
|
|
||||||
// Локальное состояние для уведомления
|
// Локальное состояние для уведомления
|
||||||
const telegramNotice = ref(false)
|
const telegramNotice = ref(false)
|
||||||
|
|
||||||
// Массив вариантов доставки
|
|
||||||
const deliveryOptions: DeliveryOption[] = [
|
|
||||||
{
|
|
||||||
label: 'В браузере (push-уведомления)',
|
|
||||||
method: 'webPushSubscription',
|
|
||||||
},
|
|
||||||
{ label: 'Telegram', method: 'telegram' },
|
|
||||||
]
|
|
||||||
|
|
||||||
// Обработчик выбора
|
// Обработчик выбора
|
||||||
function handleSelection(method: QRCodeDocument['messageDeliveryMethod']) {
|
function handleSelection(method: QRCodeDocument['messageDeliveryMethod']) {
|
||||||
if (method === 'telegram') {
|
if (method === 'telegram') {
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
<h2 class="text-xl font-semibold mb-4">Где вы хотите разместить QR‑код?</h2>
|
<h2 class="text-xl font-semibold mb-4">Где вы хотите разместить QR‑код?</h2>
|
||||||
<p class="text-gray-600 mb-4">Этот выбор поможет настроить QR‑код с подходящими действиями.</p>
|
<p class="text-gray-600 mb-4">Этот выбор поможет настроить QR‑код с подходящими действиями.</p>
|
||||||
<div class="flex flex-col gap-3 mb-4">
|
<div class="flex flex-col gap-3 mb-4">
|
||||||
<div v-for="(label, type) in qrCodePlacements" :key="type" class="flex items-center gap-2">
|
<div v-for="{ label, type } in qrCodePlacements" :key="type" class="flex items-center gap-2">
|
||||||
<RadioButton
|
<RadioButton
|
||||||
v-model="selectedPlacement"
|
v-model="selectedPlacement"
|
||||||
:inputId="type"
|
:inputId="type"
|
||||||
name="placement"
|
name="placement"
|
||||||
:value="type"
|
:value="type"
|
||||||
@change="next"
|
@change="$emit('nextStep')"
|
||||||
/>
|
/>
|
||||||
<label :for="type">{{ label }}</label>
|
<label :for="type">{{ label }}</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -18,20 +18,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const qrCodePlacements = {
|
import { qrCodePlacements } from '@/constants/qrCodePlacements'
|
||||||
car: 'Автомобиль',
|
|
||||||
pet: 'Питомец',
|
|
||||||
door: 'Входная дверь дома или квартиры',
|
|
||||||
store: 'Магазин',
|
|
||||||
restaurant_table: 'Стол в кафе или ресторане',
|
|
||||||
other: 'Другое',
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectedPlacement = defineModel<string>()
|
const selectedPlacement = defineModel<string>()
|
||||||
|
|
||||||
const emit = defineEmits(['nextStep'])
|
defineEmits(['nextStep'])
|
||||||
|
|
||||||
function next() {
|
|
||||||
emit('nextStep')
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -30,34 +30,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { watch, nextTick, useTemplateRef } from 'vue'
|
import { nextTick, useTemplateRef, watch } from 'vue'
|
||||||
import { type QRCodeDocument } from '@/types/DBDocumentTypes'
|
import { type QRCodeDocument } from '@/types/DBDocumentTypes'
|
||||||
|
import { defaultMessages } from '@/constants/defaultMessages'
|
||||||
|
|
||||||
// Пропсы
|
// Пропсы
|
||||||
const props = defineProps<{ placement: QRCodeDocument['placement'] }>()
|
const props = defineProps<{ placement: QRCodeDocument['placement'] }>()
|
||||||
const messagesRef = useTemplateRef<HTMLDivElement[]>('messagesRef')
|
const messagesRef = useTemplateRef<HTMLDivElement[]>('messagesRef')
|
||||||
|
|
||||||
// Предустановленные сообщения по типу размещения
|
|
||||||
const defaultMessages = {
|
|
||||||
car: [
|
|
||||||
'Ваш автомобиль мешает',
|
|
||||||
'Выключите свет',
|
|
||||||
'Спустило колесо',
|
|
||||||
'Подойдите к вашей машине',
|
|
||||||
'Эвакуатор',
|
|
||||||
],
|
|
||||||
pet: ['Нашёлся ваш питомец'],
|
|
||||||
door: ['Я рядом с дверью'],
|
|
||||||
store: ['Подойдите к кассе', 'Вопрос по товару', 'Помощь с покупкой'],
|
|
||||||
restaurant_table: [
|
|
||||||
'Позовите официанта',
|
|
||||||
'Принести меню',
|
|
||||||
'Принести счёт',
|
|
||||||
'Пожаловаться на обслуживание',
|
|
||||||
],
|
|
||||||
other: [],
|
|
||||||
}
|
|
||||||
|
|
||||||
// Локальное хранилище сообщений
|
// Локальное хранилище сообщений
|
||||||
const messages = defineModel<Exclude<QRCodeDocument['predefinedMessages'], undefined>>({
|
const messages = defineModel<Exclude<QRCodeDocument['predefinedMessages'], undefined>>({
|
||||||
required: true,
|
required: true,
|
||||||
@@ -67,7 +47,7 @@ const messages = defineModel<Exclude<QRCodeDocument['predefinedMessages'], undef
|
|||||||
watch(
|
watch(
|
||||||
() => props.placement,
|
() => props.placement,
|
||||||
(newPlacement, previousPlacement) => {
|
(newPlacement, previousPlacement) => {
|
||||||
let prevDefaultMessages: QRCodeDocument['predefinedMessages'] = []
|
let prevDefaultMessages: (typeof defaultMessages)[QRCodeDocument['placement']] = []
|
||||||
if (previousPlacement && previousPlacement in defaultMessages) {
|
if (previousPlacement && previousPlacement in defaultMessages) {
|
||||||
prevDefaultMessages = defaultMessages[previousPlacement]
|
prevDefaultMessages = defaultMessages[previousPlacement]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Предустановленные сообщения по типу размещения
|
||||||
|
export const defaultMessages = {
|
||||||
|
car: [
|
||||||
|
'Ваш автомобиль мешает',
|
||||||
|
'Выключите свет',
|
||||||
|
'Спустило колесо',
|
||||||
|
'Подойдите к вашей машине',
|
||||||
|
'Эвакуатор',
|
||||||
|
],
|
||||||
|
pet: ['Нашёлся ваш питомец'],
|
||||||
|
door: ['Я рядом с дверью'],
|
||||||
|
store: ['Подойдите к кассе', 'Вопрос по товару', 'Помощь с покупкой'],
|
||||||
|
restaurant_table: [
|
||||||
|
'Позовите официанта',
|
||||||
|
'Принести меню',
|
||||||
|
'Принести счёт',
|
||||||
|
'Пожаловаться на обслуживание',
|
||||||
|
],
|
||||||
|
other: [],
|
||||||
|
} as const
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Массив вариантов доставки
|
||||||
|
export const deliveryOptions = [
|
||||||
|
{
|
||||||
|
label: 'В браузере (push-уведомления)',
|
||||||
|
method: 'webPushSubscription',
|
||||||
|
},
|
||||||
|
{ label: 'Telegram', method: 'telegram' },
|
||||||
|
] as const
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export const qrCodePlacements = [
|
||||||
|
{ type: 'car', label: 'Автомобиль' },
|
||||||
|
{ type: 'pet', label: 'Питомец' },
|
||||||
|
{ type: 'door', label: 'Входная дверь дома или квартиры' },
|
||||||
|
{ type: 'store', label: 'Магазин' },
|
||||||
|
{ type: 'restaurant_table', label: 'Стол в кафе или ресторане' },
|
||||||
|
{ type: 'other', label: 'Другое' },
|
||||||
|
] as const
|
||||||
Reference in New Issue
Block a user