File size: 1,197 Bytes
c3e8f3d
abb7588
c3e8f3d
5ec491a
cb6fbf2
fcd4478
76fdff4
f80b091
76fdff4
 
fcd4478
5ec491a
cb6fbf2
 
 
 
 
f80b091
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76fdff4
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
36
import ProjectListSideBar from '@/components/project-sidebar/ProjectListSideBar';
import { Suspense } from 'react';
import Loading from '@/components/ui/Loading';
import { sessionUser } from '@/auth';
import { redirect } from 'next/navigation';

interface ChatLayoutProps {
  children: React.ReactNode;
}

export default async function Layout({ children }: ChatLayoutProps) {
  const { isAdmin } = await sessionUser();

  if (!isAdmin) {
    redirect('/');
  }

  return (
    <div className="relative flex h-[calc(100vh_-_theme(spacing.16))] overflow-hidden">
      <div
        data-state="open"
        className="peer absolute inset-y-0 z-30 hidden border-r bg-muted duration-300 ease-in-out translate-x-0 lg:flex lg:w-[250px] xl:w-[300px] h-full flex-col dark:bg-zinc-950 overflow-auto py-2"
      >
        <Suspense fallback={<Loading />}>
          <ProjectListSideBar />
        </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] peer-[[data-state=open]]:xl:pl-[300px]">
          {children}
        </div>
      </Suspense>
    </div>
  );
}