2023-06-11 00:59:16 +03:00
|
|
|
"use client";
|
2024-01-20 07:34:30 +03:00
|
|
|
import { usePathname, useRouter } from "next/navigation";
|
2024-01-21 00:23:38 +03:00
|
|
|
import { ReactNode, useEffect, useState } from "react";
|
2023-06-15 12:52:46 +03:00
|
|
|
|
2024-01-20 07:34:30 +03:00
|
|
|
import { KnowledgeToFeedProvider } from "@/lib/context";
|
2023-06-15 12:52:46 +03:00
|
|
|
|
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 => {
|
2024-01-20 07:34:30 +03:00
|
|
|
const pathname = usePathname();
|
|
|
|
const router = useRouter();
|
2024-01-21 00:23:38 +03:00
|
|
|
const [isLoading, setIsLoading] = useState(true);
|
2023-08-11 11:06:20 +03:00
|
|
|
|
2024-01-20 07:34:30 +03:00
|
|
|
useEffect(() => {
|
2024-01-20 23:04:03 +03:00
|
|
|
if (pathname === '/chat') {
|
2024-01-20 07:34:30 +03:00
|
|
|
router.push('/search');
|
2024-01-21 00:23:38 +03:00
|
|
|
} else {
|
|
|
|
setIsLoading(false);
|
2024-01-20 07:34:30 +03:00
|
|
|
}
|
2024-01-20 23:04:03 +03:00
|
|
|
}, [pathname, router]);
|
2024-01-20 07:34:30 +03:00
|
|
|
|
2024-01-21 00:23:38 +03:00
|
|
|
if (isLoading) {
|
|
|
|
return <></>
|
|
|
|
}
|
2023-06-11 00:59:16 +03:00
|
|
|
|
|
|
|
return (
|
2023-09-28 16:39:30 +03:00
|
|
|
<KnowledgeToFeedProvider>
|
2024-01-20 07:34:30 +03:00
|
|
|
<div className="relative h-full w-full flex justify-stretch items-stretch overflow-auto">
|
|
|
|
{children}
|
|
|
|
</div>
|
2023-09-28 16:39:30 +03:00
|
|
|
</KnowledgeToFeedProvider>
|
2023-06-11 00:59:16 +03:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Layout;
|