({
children,
}: {
children: React.ReactNode;
})
| 7 | import { useAuthContext } from '@/providers/AuthProvider'; |
| 8 | |
| 9 | export default function ChatLayout({ |
| 10 | children, |
| 11 | }: { |
| 12 | children: React.ReactNode; |
| 13 | }) { |
| 14 | const { isAuthorized } = useAuthContext(); |
| 15 | const [isModalOpen, setIsModalOpen] = useState(false); |
| 16 | |
| 17 | const { refetch } = useQuery(GET_USER_PROJECTS, { |
| 18 | skip: !isAuthorized, |
| 19 | }); |
| 20 | const router = useRouter(); |
| 21 | |
| 22 | useEffect(() => { |
| 23 | if (!isAuthorized) { |
| 24 | router.push('/'); |
| 25 | } |
| 26 | }, [isAuthorized, router]); |
| 27 | |
| 28 | if (!isAuthorized) { |
| 29 | return null; |
| 30 | } |
| 31 | |
| 32 | return ( |
| 33 | <main className="flex h-[calc(100dvh)] flex-col items-center"> |
| 34 | <ProjectModal |
| 35 | isOpen={isModalOpen} |
| 36 | onClose={() => setIsModalOpen(false)} |
| 37 | refetchProjects={refetch} |
| 38 | /> |
| 39 | <div className="w-full h-full">{children}</div> |
| 40 | </main> |
| 41 | ); |
| 42 | } |
nothing calls this directly
no test coverage detected