diff --git a/messages/en.json b/messages/en.json
index f52e8b4..0bac1d5 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -302,14 +302,15 @@
"pinned_chats": "Pinned Chats"
},
"message_input_placeholder": "Type a message...",
- "message_image_fallback": "Failed to load image"
+ "message_image_fallback": "Failed to load image",
+ "payment_error": "Something went wrong. Please try again later."
},
"RefillTimerModal": {
"title": "Refill credits in 1 click",
"subtitle": " {newCredits} credits for {price}",
"button": "Get Credits",
"dont_want_to_continue": "I don't want to continue chatting",
- "auto_refill_description": "Auto-refill keeps your readings uninterrupted. After using {credits} credits, we'll automatically add {addCredits} more credits ({minutes} minutes of consultation) for a one-time payment. No recurring charges.",
+ "auto_refill_description": "Auto-refill keeps your readings uninterrupted. After using {afterCredits} credits, we'll automatically add {addCredits} more credits ({minutes} minutes of consultation) for a one-time payment. No recurring charges.",
"seconds": "seconds"
},
"RefillOptionsModal": {
diff --git a/package-lock.json b/package-lock.json
index d75a97c..2b8b666 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,6 +19,7 @@
"react-dom": "^19.0.0",
"sass": "^1.89.2",
"server-only": "^0.0.1",
+ "socket.io-client": "^4.8.1",
"zod": "^3.25.64",
"zustand": "^5.0.5"
},
@@ -1286,6 +1287,12 @@
"integrity": "sha512-bXHSaW5jRTmke9Vd0h5P7BtWZG9Znqb8gSDxZnxaGSJnGwPLDPfS+3g0BKzeWqzgZPsIVZkM7m2tbo18cm5HBw==",
"license": "MIT"
},
+ "node_modules/@socket.io/component-emitter": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
+ "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==",
+ "license": "MIT"
+ },
"node_modules/@swc/counter": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz",
@@ -2624,6 +2631,45 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/engine.io-client": {
+ "version": "6.6.3",
+ "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.6.3.tgz",
+ "integrity": "sha512-T0iLjnyNWahNyv/lcjS2y4oE358tVS/SYQNxYXGAJ9/GLgH4VCvOQ/mhTjqU88mLZCQgiG8RIegFHYCdVC+j5w==",
+ "license": "MIT",
+ "dependencies": {
+ "@socket.io/component-emitter": "~3.1.0",
+ "debug": "~4.3.1",
+ "engine.io-parser": "~5.2.1",
+ "ws": "~8.17.1",
+ "xmlhttprequest-ssl": "~2.1.1"
+ }
+ },
+ "node_modules/engine.io-client/node_modules/debug": {
+ "version": "4.3.7",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
+ "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "^2.1.3"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/engine.io-parser": {
+ "version": "5.2.3",
+ "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz",
+ "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
"node_modules/es-abstract": {
"version": "1.24.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.0.tgz",
@@ -4402,7 +4448,6 @@
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
- "dev": true,
"license": "MIT"
},
"node_modules/nanoid": {
@@ -5380,6 +5425,68 @@
"is-arrayish": "^0.3.1"
}
},
+ "node_modules/socket.io-client": {
+ "version": "4.8.1",
+ "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.8.1.tgz",
+ "integrity": "sha512-hJVXfu3E28NmzGk8o1sHhN3om52tRvwYeidbj7xKy2eIIse5IoKX3USlS6Tqt3BHAtflLIkCQBkzVrEEfWUyYQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@socket.io/component-emitter": "~3.1.0",
+ "debug": "~4.3.2",
+ "engine.io-client": "~6.6.1",
+ "socket.io-parser": "~4.2.4"
+ },
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
+ "node_modules/socket.io-client/node_modules/debug": {
+ "version": "4.3.7",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
+ "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "^2.1.3"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/socket.io-parser": {
+ "version": "4.2.4",
+ "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
+ "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==",
+ "license": "MIT",
+ "dependencies": {
+ "@socket.io/component-emitter": "~3.1.0",
+ "debug": "~4.3.1"
+ },
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
+ "node_modules/socket.io-parser/node_modules/debug": {
+ "version": "4.3.7",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
+ "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "^2.1.3"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
"node_modules/source-map-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
@@ -5998,6 +6105,35 @@
"node": ">=0.10.0"
}
},
+ "node_modules/ws": {
+ "version": "8.17.1",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
+ "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.0.0"
+ },
+ "peerDependencies": {
+ "bufferutil": "^4.0.1",
+ "utf-8-validate": ">=5.0.2"
+ },
+ "peerDependenciesMeta": {
+ "bufferutil": {
+ "optional": true
+ },
+ "utf-8-validate": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/xmlhttprequest-ssl": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.1.2.tgz",
+ "integrity": "sha512-TEU+nJVUUnA4CYJFLvK5X9AOeH4KvDvhIfm0vV1GaQRtchnG0hgK5p8hw/xjv8cunWYCsiPCSDzObPyhEwq3KQ==",
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
diff --git a/package.json b/package.json
index 8e89db8..4e635de 100644
--- a/package.json
+++ b/package.json
@@ -24,6 +24,7 @@
"react-dom": "^19.0.0",
"sass": "^1.89.2",
"server-only": "^0.0.1",
+ "socket.io-client": "^4.8.1",
"zod": "^3.25.64",
"zustand": "^5.0.5"
},
diff --git a/src/app/[locale]/(chat)/chat/[assistantId]/layout.tsx b/src/app/[locale]/(chat)/chat/[assistantId]/layout.tsx
new file mode 100644
index 0000000..b7cdd0e
--- /dev/null
+++ b/src/app/[locale]/(chat)/chat/[assistantId]/layout.tsx
@@ -0,0 +1,30 @@
+import { createChat, getChatMessages } from "@/entities/chats/api";
+import type { IChatMessage } from "@/entities/chats/types";
+import { ChatProvider } from "@/providers/chat-provider";
+
+export default async function ChatLayout({
+ children,
+ params,
+}: Readonly<{
+ children: React.ReactNode;
+ params: Promise<{ assistantId: string }>;
+}>) {
+ const { assistantId } = await params;
+
+ const { chatId } = await createChat(assistantId);
+
+ const { messages: initialMessages, totalCount } = await getChatMessages(
+ chatId,
+ { limit: 50, page: 1 }
+ );
+
+ return (
+
+ {children}
+
+ );
+}
diff --git a/src/app/[locale]/(chat)/chat/[assistantId]/page.module.scss b/src/app/[locale]/(chat)/chat/[assistantId]/page.module.scss
new file mode 100644
index 0000000..d7b23e8
--- /dev/null
+++ b/src/app/[locale]/(chat)/chat/[assistantId]/page.module.scss
@@ -0,0 +1,5 @@
+.container {
+ display: flex;
+ flex-direction: column;
+ height: 100dvh;
+}
diff --git a/src/app/[locale]/(chat)/chat/[assistantId]/page.tsx b/src/app/[locale]/(chat)/chat/[assistantId]/page.tsx
new file mode 100644
index 0000000..eef4ad4
--- /dev/null
+++ b/src/app/[locale]/(chat)/chat/[assistantId]/page.tsx
@@ -0,0 +1,19 @@
+import {
+ ChatHeader,
+ ChatMessagesWrapper,
+ ChatModalsWrapper,
+ MessageInputWrapper,
+} from "@/components/domains/chat";
+
+import styles from "./page.module.scss";
+
+export default function Chat() {
+ return (
+
+
+
+
+
+
+ );
+}
diff --git a/src/app/[locale]/(chat)/chat/[id]/page.tsx b/src/app/[locale]/(chat)/chat/[id]/page.tsx
deleted file mode 100644
index fa58044..0000000
--- a/src/app/[locale]/(chat)/chat/[id]/page.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-"use client";
-// TODO: client component
-
-import { useEffect, useRef, useState } from "react";
-
-import {
- ChatHeader,
- ChatMessageProps,
- ChatMessages,
- MessageInput,
- RefillOptionsModal,
- RefillTimerModal,
-} from "@/components/domains/chat";
-import { Button, ModalSheet } from "@/components/ui";
-import { formatTime } from "@/shared/utils/date";
-
-import styles from "./page.module.scss";
-
-const staticMessages: ChatMessageProps["message"][] = [
- {
- id: "1",
- type: "text",
- content: "It was absolutely amazing! The views were incredible 🏔️",
- isOwn: true,
- isRead: true,
- time: "12:09 AM",
- },
- {
- id: "2",
- type: "text",
- content:
- "Same here, everything's good. Have you made any plans for vacation yet?",
- isOwn: false,
- time: "12:09 AM",
- },
- {
- id: "4",
- type: "image",
- content: "What if we take a vacation?",
- imageUrl: "/test-user-avatar.png",
- isOwn: false,
- time: "12:09 AM",
- },
- {
- id: "5",
- type: "image",
- content: "What if we take a vacation?",
- imageUrl: "/adviser-card.png",
- isOwn: false,
- time: "12:09 AM",
- },
- {
- id: "6",
- type: "image",
- content:
- "What if we take a vacation? What if we take a vacation? What if we take a vacation? What if we take a vacation? What if we take a vacation? What if we take a vacation? What if we take a vacation? ",
- imageUrl: "/adviser-card.png",
- isOwn: false,
- time: "12:09 AM",
- },
- {
- id: "7",
- type: "text",
- content: "test",
- isOwn: true,
- isRead: false,
- time: "12:09 AM",
- },
-];
-
-export default function Chat() {
- const messagesWrapperRef = useRef(null);
-
- const [messages, setMessages] =
- useState(staticMessages);
-
- const [isModalOpen, setIsModalOpen] = useState(false);
- const [modalChild, setModalChild] = useState<
- "refill-timer" | "refill-options"
- >("refill-timer");
-
- useEffect(() => {
- if (messagesWrapperRef.current) {
- messagesWrapperRef.current.scrollTo({
- top: messagesWrapperRef.current.scrollHeight,
- behavior: "smooth",
- });
- }
- }, [messages]);
-
- const handleSend = (message: string) => {
- setMessages(prev => {
- const newMessage = {
- id: `${prev.length + 2}`,
- type: "text",
- content: message,
- isOwn: true,
- time: formatTime(new Date().toISOString()),
- } as ChatMessageProps["message"];
-
- return [...prev, newMessage];
- });
- };
-
- const handleModalClose = () => {
- setIsModalOpen(false);
- const timeout = setTimeout(() => {
- setModalChild("refill-timer");
- }, 300);
-
- return () => clearTimeout(timeout);
- };
-
- return (
-
-
-
-
-
-
-
-
-
-
- {modalChild === "refill-timer" && (
- setModalChild("refill-options")}
- />
- )}
- {modalChild === "refill-options" && }
-
-
- );
-}
diff --git a/src/app/[locale]/(chat)/chat/page.tsx b/src/app/[locale]/(chat)/chat/page.tsx
index 21e3590..b158fdd 100644
--- a/src/app/[locale]/(chat)/chat/page.tsx
+++ b/src/app/[locale]/(chat)/chat/page.tsx
@@ -1,103 +1,39 @@
-"use client";
-// TODO: CLIENT PAGE
-
-import { useState } from "react";
-import { useTranslations } from "next-intl";
+import { Suspense } from "react";
import {
- CategoryChats,
- ChatItemsList,
+ ChatCategories,
+ ChatCategoriesSkeleton,
ChatListHeader,
- CorrespondenceStarted,
- NewMessages,
+ CorrespondenceStartedSkeleton,
+ CorrespondenceStartedWrapper,
+ NewMessagesWrapper,
+ NewMessagesWrapperSkeleton,
} from "@/components/domains/chat";
import { NavigationBar } from "@/components/layout";
-import { ChipProps } from "@/components/ui";
-import { ChatItemProps } from "@/components/widgets";
-import Chips from "@/components/widgets/Chips/Chips";
+import {
+ loadCategorizedChats,
+ loadCorrespondenceStarted,
+ loadUnreadChats,
+} from "@/entities/chats/loaders";
import styles from "./page.module.scss";
-const messages: ChatItemProps[] = [
- {
- userAvatar: {
- src: "/test-user-avatar.png",
- alt: `${"Aaron (Taro)"} avatar`,
- isOnline: true,
- },
- name: "Aaron (Taro)",
- messagePreiew: {
- message: {
- type: "image",
- content: "",
- },
- isRead: true,
- },
- badgeContent: "3",
- time: "09:00 AM",
- },
- {
- userAvatar: {
- src: "/test-user-avatar.png",
- alt: `${"Aaron (Taro)"} avatar`,
- isOnline: true,
- },
- name: "Aaron (Taro)",
- messagePreiew: {
- message: {
- type: "image",
- content: "",
- },
- isRead: true,
- },
- badgeContent: "3",
- time: "09:00 AM",
- },
-];
-
-const chips: Omit[] = [
- {
- text: "All",
- },
- {
- text: "Психологи Отношений",
- },
- {
- text: "Астрологи",
- },
- {
- text: "Таро",
- },
- {
- text: "Нумерологи",
- },
-];
-
export default function Chats() {
- const t = useTranslations("Chat");
- const [activeChip, setActiveChip] = useState("All");
-
return (
-
-
-
-
-
-
- setActiveChip(chip.text)}
- />
-
-
-
-
-
-
+ }>
+
+
+ }>
+
+
+ }>
+
+
diff --git a/src/app/[locale]/(chat)/layout.tsx b/src/app/[locale]/(chat)/layout.tsx
index 448d0fb..8b5232e 100644
--- a/src/app/[locale]/(chat)/layout.tsx
+++ b/src/app/[locale]/(chat)/layout.tsx
@@ -1,3 +1,5 @@
+import { ChatStoreProvider } from "@/providers/chat-store-provider";
+
import styles from "./layout.module.scss";
export default function ChatLayout({
@@ -6,8 +8,8 @@ export default function ChatLayout({
children: React.ReactNode;
}>) {
return (
- <>
+
{children}
- >
+
);
}
diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx
index 85b1a91..b416ecf 100644
--- a/src/app/[locale]/layout.tsx
+++ b/src/app/[locale]/layout.tsx
@@ -9,9 +9,13 @@ import { hasLocale, NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import clsx from "clsx";
+import { loadUser, loadUserId } from "@/entities/user/loaders";
import { routing } from "@/i18n/routing";
+import { ChatsInitializationProvider } from "@/providers/chats-initialization-provider";
import { RetainingStoreProvider } from "@/providers/retaining-store-provider";
+import SocketProvider from "@/providers/socket-provider";
import { ToastProvider } from "@/providers/toast-provider";
+import { UserProvider } from "@/providers/user-provider";
import styles from "./layout.module.scss";
@@ -45,13 +49,22 @@ export default async function RootLayout({
const messages = await getMessages();
+ const user = await loadUser();
+ const userId = await loadUserId();
+
return (
-
- {children}
-
+
+
+
+
+ {children}
+
+
+
+
diff --git a/src/components/domains/chat/CategoryChats/CategoryChats.tsx b/src/components/domains/chat/CategoryChats/CategoryChats.tsx
index 36c94f3..565d475 100644
--- a/src/components/domains/chat/CategoryChats/CategoryChats.tsx
+++ b/src/components/domains/chat/CategoryChats/CategoryChats.tsx
@@ -1,19 +1,55 @@
-import { ChatItem, ChatItemProps } from "@/components/widgets";
+"use client";
+
+import { useRouter } from "next/navigation";
+
+import { ChatItem } from "@/components/widgets";
+import { IChat } from "@/entities/chats/types";
+import { useChatStore } from "@/providers/chat-store-provider";
+import { ROUTES } from "@/shared/constants/client-routes";
+import { formatTime } from "@/shared/utils/date";
import styles from "./CategoryChats.module.scss";
interface CategoryChatsProps {
- messages: ChatItemProps[];
+ chats: IChat[];
+ maxVisibleChats?: number;
}
-export default function CategoryChats({ messages }: CategoryChatsProps) {
+export default function CategoryChats({
+ chats,
+ maxVisibleChats = 3,
+}: CategoryChatsProps) {
+ const router = useRouter();
+ const setCurrentChat = useChatStore(state => state.setCurrentChat);
+
return (
- {messages.map((message, index) => (
+ {chats.slice(0, maxVisibleChats).map(chat => (
{
+ setCurrentChat(chat);
+ router.push(ROUTES.chat(chat.assistantId));
+ }}
/>
))}
diff --git a/src/components/domains/chat/ChatCategories/ChatCategories.tsx b/src/components/domains/chat/ChatCategories/ChatCategories.tsx
new file mode 100644
index 0000000..7f851f9
--- /dev/null
+++ b/src/components/domains/chat/ChatCategories/ChatCategories.tsx
@@ -0,0 +1,68 @@
+"use client";
+
+import { use, useState } from "react";
+
+import { Skeleton } from "@/components/ui";
+import { Chips } from "@/components/widgets";
+import { ICategorizedChats } from "@/entities/chats/types";
+
+import { CategoryChats, ChatItemsList } from "..";
+
+interface ChatCategoriesProps {
+ chatsPromise: Promise;
+}
+
+export default function ChatCategories({ chatsPromise }: ChatCategoriesProps) {
+ const chats = use(chatsPromise);
+ const [activeChip, setActiveChip] = useState("All");
+ const [maxVisibleChats, setMaxVisibleChats] = useState<
+ Partial>
+ >({});
+
+ const chips = Object.keys(chats).map(key => ({
+ text: key,
+ }));
+ chips.unshift({
+ text: "All",
+ });
+
+ const filteredChats = Object.keys(chats).filter(key => {
+ if (activeChip === "All") return true;
+ return chats[key].some(chat => chat.category === activeChip);
+ });
+
+ return (
+ <>
+ setActiveChip(chip.text)}
+ />
+
+ {filteredChats.map(key => (
+ {
+ setMaxVisibleChats(prev => ({
+ ...prev,
+ [key]: !!prev[key] ? null : chats[key].length,
+ }));
+ },
+ }}
+ >
+
+
+ ))}
+ >
+ );
+}
+
+export const ChatCategoriesSkeleton = () => {
+ return ;
+};
diff --git a/src/components/domains/chat/ChatHeader/ChatHeader.module.scss b/src/components/domains/chat/ChatHeader/ChatHeader.module.scss
index 4bf2205..e32de2b 100644
--- a/src/components/domains/chat/ChatHeader/ChatHeader.module.scss
+++ b/src/components/domains/chat/ChatHeader/ChatHeader.module.scss
@@ -44,11 +44,16 @@
& > .avatar {
border-radius: 50%;
+ width: 48px;
+ height: 48px;
+ // background-color: #f3f4f6;
+ background: linear-gradient(90deg, #3b82f6 0%, #4f46e5 100%);
}
& > .chatInfoContent {
- display: flex;
- flex-direction: column;
+ display: grid;
+ grid-template-rows: 1fr 14px;
+ justify-items: start;
gap: 2px;
& > .name {
diff --git a/src/components/domains/chat/ChatHeader/ChatHeader.tsx b/src/components/domains/chat/ChatHeader/ChatHeader.tsx
index e96a3b0..c32af4c 100644
--- a/src/components/domains/chat/ChatHeader/ChatHeader.tsx
+++ b/src/components/domains/chat/ChatHeader/ChatHeader.tsx
@@ -1,20 +1,34 @@
"use client";
+import { useEffect, useState } from "react";
import Image from "next/image";
import { useRouter } from "next/navigation";
+import { useTranslations } from "next-intl";
-import {
- Badge,
- Icon,
- IconName,
- OnlineIndicator,
- Typography,
-} from "@/components/ui";
+import { Icon, IconName, OnlineIndicator, Typography } from "@/components/ui";
+import { useChat } from "@/providers/chat-provider";
+import { useChatStore } from "@/providers/chat-store-provider";
+import { formatSecondsToHHMMSS } from "@/shared/utils/date";
+import { delay } from "@/shared/utils/delay";
import styles from "./ChatHeader.module.scss";
export default function ChatHeader() {
+ const t = useTranslations("Chat");
const router = useRouter();
+ const currentChat = useChatStore(state => state.currentChat);
+ const { isLoadingAdvisorMessage, isAvailableChatting } = useChat();
+
+ const [timer, setTimer] = useState(0);
+
+ useEffect(() => {
+ (async () => {
+ await delay(1000);
+ if (isAvailableChatting) {
+ setTimer(timer + 1);
+ }
+ })();
+ }, [isAvailableChatting, timer]);
return (