2023-06-11 00:59:16 +03:00
|
|
|
"use client";
|
2023-06-15 12:52:46 +03:00
|
|
|
import { ReactNode } from "react";
|
|
|
|
|
2023-09-28 16:39:30 +03:00
|
|
|
import { ChatProvider, KnowledgeToFeedProvider } from "@/lib/context";
|
2023-06-15 12:52:46 +03:00
|
|
|
import { ChatsProvider } from "@/lib/context/ChatsProvider/chats-provider";
|
2023-06-20 17:17:13 +03:00
|
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
2023-07-13 19:05:08 +03:00
|
|
|
import { redirectToLogin } from "@/lib/router/redirectToLogin";
|
2023-06-15 12:52:46 +03:00
|
|
|
|
2023-11-02 21:20:07 +03:00
|
|
|
import { ChatsList, NotificationBanner } from "./components";
|
2023-06-11 00:59:16 +03:00
|
|
|
|
|
|
|
interface LayoutProps {
|
|
|
|
children?: ReactNode;
|
|
|
|
}
|
|
|
|
|
2023-06-15 12:52:46 +03:00
|
|
|
const Layout = ({ children }: LayoutProps): JSX.Element => {
|
2023-06-11 00:59:16 +03:00
|
|
|
const { session } = useSupabase();
|
2023-08-11 11:06:20 +03:00
|
|
|
|
2023-06-20 17:17:13 +03:00
|
|
|
if (session === null) {
|
2023-07-13 19:05:08 +03:00
|
|
|
redirectToLogin();
|
2023-06-15 12:52:46 +03:00
|
|
|
}
|
2023-06-11 00:59:16 +03:00
|
|
|
|
|
|
|
return (
|
2023-09-28 16:39:30 +03:00
|
|
|
<KnowledgeToFeedProvider>
|
2023-09-28 12:29:55 +03:00
|
|
|
<ChatsProvider>
|
|
|
|
<ChatProvider>
|
2023-11-02 21:20:07 +03:00
|
|
|
<NotificationBanner />
|
2023-11-06 16:36:21 +03:00
|
|
|
<div className="relative h-full w-full flex justify-stretch items-stretch overflow-auto">
|
2023-10-05 19:03:46 +03:00
|
|
|
<ChatsList />
|
|
|
|
{children}
|
|
|
|
</div>
|
2023-09-28 12:29:55 +03:00
|
|
|
</ChatProvider>
|
|
|
|
</ChatsProvider>
|
2023-09-28 16:39:30 +03:00
|
|
|
</KnowledgeToFeedProvider>
|
2023-06-11 00:59:16 +03:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Layout;
|