@@ -69,7 +69,6 @@ const {
|
||||
} = useMutation({
|
||||
mutationKey: ['createQrCode'],
|
||||
mutationFn: async () => {
|
||||
throw new Error('wtf')
|
||||
const qrCodeDocument = await createQrCodeDocument({
|
||||
name: name.value,
|
||||
placement: placement.value!,
|
||||
|
||||
@@ -8,37 +8,20 @@
|
||||
/>
|
||||
</MetaHead>
|
||||
|
||||
<div class="flex flex-col min-h-full">
|
||||
<!-- Основной контент -->
|
||||
<main class="flex-grow flex flex-col">
|
||||
<section class="flex flex-col flex-grow max-w-prose w-full mx-auto">
|
||||
<ChatComponent userRole="guest" :qr_code_uri="qr_code_uri" :chat="chat">
|
||||
<template #endOfMessages="{ count, lastMessage }">
|
||||
<!-- Уведомление, если гость отправил только одно сообщение -->
|
||||
<div
|
||||
v-if="count === 1 && lastMessage && lastMessage.from === 'guest'"
|
||||
class="flex flex-col items-center justify-center text-center bg-gray-50 border border-gray-200 rounded-lg shadow-md p-6 mt-6"
|
||||
>
|
||||
<p class="text-gray-700 font-medium text-lg">Ваше сообщение отправлено.</p>
|
||||
<p class="text-gray-600 mt-2">
|
||||
Вы можете написать ещё одно сообщение или подождать ответа.
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
</ChatComponent>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<!-- Футер -->
|
||||
<!-- <footer class="bg-gray-100 text-center py-4 border-t text-sm text-gray-700">-->
|
||||
<!-- <p><a href="/create" class="underline underline-offset-2">Создайте свой QR‑код</a>.</p>-->
|
||||
<!-- <p class="mt-1">-->
|
||||
<!-- Сделайте НаСвязи удобнее. Будем рады вашей <a href="/donate" class="underline underline-offset-2"-->
|
||||
<!-- >поддержке</a-->
|
||||
<!-- >.-->
|
||||
<!-- </p>-->
|
||||
<!-- </footer>-->
|
||||
</div>
|
||||
<ChatComponent userRole="guest" :qr_code_uri="qr_code_uri" :chat="chat">
|
||||
<template #endOfMessages="{ count, lastMessage }">
|
||||
<!-- Уведомление, если гость отправил только одно сообщение -->
|
||||
<div
|
||||
v-if="count === 1 && lastMessage && lastMessage.from === 'guest'"
|
||||
class="flex flex-col items-center justify-center text-center bg-gray-50 border border-gray-200 rounded-lg shadow-md p-6 mt-6"
|
||||
>
|
||||
<p class="text-gray-700 font-medium text-lg">Ваше сообщение отправлено.</p>
|
||||
<p class="text-gray-600 mt-2">
|
||||
Вы можете написать ещё одно сообщение или подождать ответа.
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
</ChatComponent>
|
||||
</LayoutWithTabs>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -11,13 +11,14 @@
|
||||
<QueryRender :query="query">
|
||||
<template #default="{ data }">
|
||||
<div
|
||||
v-if="data.rows.length > 0"
|
||||
v-if="data.length > 0"
|
||||
class="justify-self-start align-baseline-start flex flex-col gap-4"
|
||||
>
|
||||
<ChatCard
|
||||
v-for="{ doc: chatDoc } in data.rows.filter((row) => !!row.doc)"
|
||||
:key="`${chatDoc!._id}`"
|
||||
:chatDoc="chatDoc!"
|
||||
v-for="row in data"
|
||||
:key="row.id"
|
||||
:chatDoc="row.doc!"
|
||||
:qrCodeDoc="row.qrCodeDoc"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -44,19 +45,32 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { chatsDbRemote } from '@/api/dbs'
|
||||
import { chatsDbRemote, qrCodeDbLocal } from '@/api/dbs'
|
||||
import { getUserUuid } from '@/utils/getUserUuid'
|
||||
import { type QRCodeDocument } from '@hereconnect/types'
|
||||
|
||||
const user_uuid = getUserUuid()
|
||||
const query = useQuery({
|
||||
queryKey: ['qrCodes'],
|
||||
queryFn: () => {
|
||||
const user_uuid = getUserUuid()
|
||||
return chatsDbRemote.allDocs({
|
||||
queryKey: ['chats', user_uuid],
|
||||
queryFn: async () => {
|
||||
const { rows } = await chatsDbRemote.allDocs({
|
||||
startkey: `chat:${user_uuid}:`,
|
||||
endkey: `chat:${user_uuid}:\uffff`,
|
||||
limit: Number.MAX_SAFE_INTEGER,
|
||||
include_docs: true,
|
||||
})
|
||||
const qrCodes = await qrCodeDbLocal.allDocs({
|
||||
keys: rows.map((row) => `qr_code:${row.doc!.qr_code_uri}`),
|
||||
include_docs: true,
|
||||
})
|
||||
const result: ((typeof rows)[number] & { qrCodeDoc?: QRCodeDocument })[] = []
|
||||
qrCodes.rows.forEach((row, index) => {
|
||||
result[index] = rows[index]
|
||||
if ('doc' in row) {
|
||||
result[index].qrCodeDoc = row.doc!
|
||||
}
|
||||
})
|
||||
return result
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user