diff --git a/src/app/(protected)/projects/[slug]/page.tsx b/src/app/(protected)/projects/[slug]/page.tsx index 585cb46..deb5137 100644 --- a/src/app/(protected)/projects/[slug]/page.tsx +++ b/src/app/(protected)/projects/[slug]/page.tsx @@ -7,10 +7,16 @@ import Sidebar from "@/components/Sidebar"; import KanbanBoard from "@/components/KanbanBoard"; import ChatPanel from "@/components/ChatPanel"; +const TABS = [ + { key: "board", label: "📋 Доска" }, + { key: "chat", label: "💬 Чат" }, +]; + export default function ProjectPage() { const { slug } = useParams<{ slug: string }>(); const [projects, setProjects] = useState([]); const [loading, setLoading] = useState(true); + const [activeTab, setActiveTab] = useState("board"); useEffect(() => { getProjects() @@ -33,17 +39,44 @@ export default function ProjectPage() {
-
-
-

{project.name}

- {project.description && ( -

{project.description}

- )} +
+
+
+

{project.name}

+ {project.description && ( +

{project.description}

+ )} +
+
+
+ {TABS.map((tab) => ( + + ))}
- {project.chat_id && } +
- + {activeTab === "board" && ( + + )} + {activeTab === "chat" && project.chat_id && ( + + )} + {activeTab === "chat" && !project.chat_id && ( +
+ Чат недоступен +
+ )}
diff --git a/src/components/ChatPanel.tsx b/src/components/ChatPanel.tsx index a11ea9d..50ae459 100644 --- a/src/components/ChatPanel.tsx +++ b/src/components/ChatPanel.tsx @@ -12,9 +12,10 @@ const AUTHOR_ICON: Record = { interface Props { chatId: string; + fullscreen?: boolean; } -export default function ChatPanel({ chatId }: Props) { +export default function ChatPanel({ chatId, fullscreen = false }: Props) { const [messages, setMessages] = useState([]); const [input, setInput] = useState(""); const [open, setOpen] = useState(false); @@ -27,7 +28,6 @@ export default function ChatPanel({ chatId }: Props) { } }, [chatId]); - // Listen for new messages via WS useEffect(() => { const unsub = wsClient.on("message.new", (data: any) => { if (data.chat_id === chatId) { @@ -51,12 +51,53 @@ export default function ChatPanel({ chatId }: Props) { setMessages((prev) => [...prev, msg]); } catch (e) { console.error("Failed to send:", e); - setInput(text); // restore on error + setInput(text); } finally { setSending(false); } }; + if (fullscreen) { + return ( +
+
+ {messages.map((msg) => ( +
+
+ {AUTHOR_ICON[msg.author_type] || "👤"} + {msg.author_slug} + · + {new Date(msg.created_at).toLocaleString("ru-RU", { hour: "2-digit", minute: "2-digit" })} +
+
{msg.content}
+
+ ))} + {messages.length === 0 && ( +
Нет сообщений
+ )} +
+
+
+ setInput(e.target.value)} + onKeyDown={(e) => e.key === "Enter" && handleSend()} + placeholder="Сообщение..." + className="flex-1 bg-[var(--bg)] border border-[var(--border)] rounded-lg px-4 py-2 text-sm outline-none focus:border-[var(--accent)]" + /> + +
+
+ ); + } + + // Compact mode (collapsible) return (