From d371d666aaa479905bc3f0a7e80a10c722a64ff3 Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 23 Jul 2025 12:05:33 +0300 Subject: [PATCH] fix floating support chat --- src/ui_kit/FloatingSupportChat/Chat.tsx | 23 ++++++++++++++--------- src/ui_kit/FloatingSupportChat/index.tsx | 12 +++++++++--- src/utils/hooks/useAutoPay.ts | 7 ------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/ui_kit/FloatingSupportChat/Chat.tsx b/src/ui_kit/FloatingSupportChat/Chat.tsx index ab7f231f..5e6046d1 100644 --- a/src/ui_kit/FloatingSupportChat/Chat.tsx +++ b/src/ui_kit/FloatingSupportChat/Chat.tsx @@ -30,7 +30,18 @@ interface Props { sendFile: (a: File | undefined) => Promise; } -const greetingMessage = "Здравствуйте, задайте ваш вопрос и наш оператор вам ответит в течение 10 минут"; +const greetingMessage: TicketMessage = { + id: "greeting", + ticket_id: "", + user_id: "system", + session_id: "", + message: "Здравствуйте, задайте ваш вопрос и наш оператор вам ответит в течение 10 минут", + files: [], + shown: {}, + request_screenshot: "", + created_at: new Date().toISOString(), + system: false +}; export default function Chat({ open = false, @@ -197,10 +208,7 @@ export default function Chat({ > {ticket.sessionData?.ticketId && messages.map((message) => { - const isSelf = useMemo(() => - (ticket.sessionData?.sessionId || user) === message.user_id, - [ticket.sessionData?.sessionId, user, message.user_id] - ); + const isSelf = (ticket.sessionData?.sessionId || user) === message.user_id; return ( - (ticket.sessionData?.sessionId || user) === greetingMessage.user_id, - [ticket.sessionData?.sessionId, user, greetingMessage.user_id] - )} + isSelf={false} /> )} diff --git a/src/ui_kit/FloatingSupportChat/index.tsx b/src/ui_kit/FloatingSupportChat/index.tsx index d50fd684..dc0830b5 100644 --- a/src/ui_kit/FloatingSupportChat/index.tsx +++ b/src/ui_kit/FloatingSupportChat/index.tsx @@ -130,9 +130,15 @@ export default () => { ({ shown }) => shown?.me !== 1, ); - newMessages.forEach(({ id, user_id }) => { - if ((ticket.sessionData?.sessionId || user) === user_id) shownMessage(id); - }); + // Находим последнее сообщение, которое не от пользователя + const lastNonUserMessage = newMessages + .filter(({ user_id }) => (ticket.sessionData?.sessionId || user) !== user_id) + .pop(); + + // Отправляем shown только на последнее сообщение, которое не от пользователя + if (lastNonUserMessage) { + shownMessage(lastNonUserMessage.id); + } } }, [isChatOpened, ticket.messages]); diff --git a/src/utils/hooks/useAutoPay.ts b/src/utils/hooks/useAutoPay.ts index 116fb66e..c1a79df3 100644 --- a/src/utils/hooks/useAutoPay.ts +++ b/src/utils/hooks/useAutoPay.ts @@ -28,13 +28,6 @@ export const useAfterPay = () => { let URLadditionalinformation = searchParams.get("additionalinformation");//его токен useEffect(() => { - console.log("useAutoPay: Processing return from payment", { - URLaction, - URLuserId, - URLadditionalinformation, - userId, - wayback: searchParams.get("wayback") - }); setSearchParams({}, { replace: true });