2025-12-11 11:31:56 +00:00
|
|
|
'use client';
|
2025-12-09 09:13:46 +00:00
|
|
|
|
2025-12-11 11:31:56 +00:00
|
|
|
import { IconButton } from '@/components/ui/button';
|
|
|
|
|
import Input from './Input';
|
|
|
|
|
import MessageList from './MessageList';
|
2025-12-18 10:14:12 +00:00
|
|
|
import SettingDialog from './Drawer';
|
|
|
|
|
import { useStreamChatStore } from '@/app/(main)/chat/[id]/stream-chat';
|
2025-12-17 10:13:47 +00:00
|
|
|
import { useParams } from 'next/navigation';
|
|
|
|
|
import { useEffect, useState } from 'react';
|
2025-12-09 09:13:46 +00:00
|
|
|
|
|
|
|
|
export default function ChatPage() {
|
2025-12-17 10:13:47 +00:00
|
|
|
const { id } = useParams();
|
|
|
|
|
const [settingOpen, setSettingOpen] = useState(false);
|
|
|
|
|
const switchToChannel = useStreamChatStore((s) => s.switchToChannel);
|
|
|
|
|
const client = useStreamChatStore((s) => s.client);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (id && client) {
|
|
|
|
|
switchToChannel(id as string);
|
|
|
|
|
}
|
|
|
|
|
}, [id, client]);
|
2025-12-09 09:13:46 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex h-full">
|
2025-12-15 11:31:18 +00:00
|
|
|
<div className="relative px-4 w-full flex-1 flex justify-center">
|
2025-12-09 09:13:46 +00:00
|
|
|
<div className="max-w-[752px] w-full h-full flex flex-col">
|
|
|
|
|
<MessageList />
|
|
|
|
|
<Input />
|
|
|
|
|
</div>
|
|
|
|
|
<IconButton
|
2025-12-17 10:13:47 +00:00
|
|
|
onClick={() => setSettingOpen(!settingOpen)}
|
2025-12-18 10:59:55 +00:00
|
|
|
className="absolute top-2 right-2"
|
2025-12-09 09:13:46 +00:00
|
|
|
variant="ghost"
|
|
|
|
|
size="small"
|
|
|
|
|
>
|
2025-12-18 10:59:55 +00:00
|
|
|
<i className="iconfont-v2 iconv2-zhankai-1" />
|
2025-12-09 09:13:46 +00:00
|
|
|
</IconButton>
|
|
|
|
|
</div>
|
2025-12-17 10:13:47 +00:00
|
|
|
<SettingDialog open={settingOpen} onOpenChange={setSettingOpen} />
|
2025-12-09 09:13:46 +00:00
|
|
|
</div>
|
2025-12-11 11:31:56 +00:00
|
|
|
);
|
2025-12-09 09:13:46 +00:00
|
|
|
}
|