Spaces:
Sleeping
Sleeping
File size: 1,240 Bytes
5ec491a c3e8f3d 5ec491a c3e8f3d f80b091 c3e8f3d 5ec491a 9333689 f80b091 7415500 f80b091 d0a1b70 f80b091 c3e8f3d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import { sessionUser } from '@/auth';
import ChatSidebarList from '@/components/chat-sidebar/ChatListSidebar';
import Loading from '@/components/ui/Loading';
import { dbGetAllChat } from '@/lib/db/functions';
import { Suspense } from 'react';
interface ChatLayoutProps {
children: React.ReactNode;
}
export default async function Layout({ children }: ChatLayoutProps) {
const { email, user, id } = await sessionUser();
const chats = await dbGetAllChat();
return (
<div className="relative flex h-[calc(100vh_-_theme(spacing.16))] overflow-hidden">
{user && (
<div
data-state={email ? 'open' : 'closed'}
className="peer absolute inset-y-0 z-30 hidden border-r bg-muted duration-300 ease-in-out -translate-x-full data-[state=open]:translate-x-0 lg:flex lg:w-[250px] h-full flex-col overflow-auto py-2"
>
<Suspense fallback={<Loading />}>
<ChatSidebarList chats={chats} />
</Suspense>
</div>
)}
<Suspense fallback={<Loading />}>
<div className="group w-full overflow-auto pl-0 animate-in duration-300 ease-in-out peer-[[data-state=open]]:lg:pl-[250px]">
{children}
</div>
</Suspense>
</div>
);
}
|