2023-07-07 13:56:08 +03:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
import { PropsWithChildren, useEffect } from "react";
|
|
|
|
|
|
|
|
import Footer from "@/lib/components/Footer";
|
|
|
|
import { NavBar } from "@/lib/components/NavBar";
|
|
|
|
import { TrackingWrapper } from "@/lib/components/TrackingWrapper";
|
|
|
|
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
|
2023-07-17 16:45:18 +03:00
|
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
2023-08-07 15:13:41 +03:00
|
|
|
import '../lib/config/LocaleConfig/i18n'
|
|
|
|
import { UpdateMetadata } from "@/lib/helpers/updateMetadata";
|
2023-07-07 13:56:08 +03:00
|
|
|
|
|
|
|
// This wrapper is used to make effect calls at a high level in app rendering.
|
|
|
|
export const App = ({ children }: PropsWithChildren): JSX.Element => {
|
|
|
|
const { fetchAllBrains, fetchAndSetActiveBrain } = useBrainContext();
|
2023-07-17 16:45:18 +03:00
|
|
|
const { session } = useSupabase();
|
2023-07-07 13:56:08 +03:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
void fetchAllBrains();
|
|
|
|
void fetchAndSetActiveBrain();
|
2023-07-17 16:45:18 +03:00
|
|
|
}, [session?.user]);
|
2023-07-07 13:56:08 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<TrackingWrapper />
|
|
|
|
<NavBar />
|
|
|
|
<div className="flex-1">{children}</div>
|
|
|
|
<Footer />
|
2023-08-07 15:13:41 +03:00
|
|
|
<UpdateMetadata />
|
2023-07-07 13:56:08 +03:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|