quivr/frontend/app/App.tsx
Mamadou DICKO 0cc917ea9e
feat: add Menu bar (#1885)
Issue: https://github.com/StanGirard/quivr/issues/1884

- Add new sidebar (Menu)
- Add Menu to App level (shared accross all pages) and display it only
on chat bar
- Remove chatlist from sidebar (they are now accessible through Actions
bar (plus button on right of chat input)
- Move notification banner to App.tsx
- Update translations

Demo:



https://github.com/StanGirard/quivr/assets/63923024/53b1bf3b-db1a-49d7-ae84-80423d66ec03
2023-12-14 10:15:38 +01:00

60 lines
1.8 KiB
TypeScript

"use client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { PropsWithChildren, useEffect } from "react";
import { Menu } from "@/lib/components/Menu/Menu";
import { NotificationBanner } from "@/lib/components/NotificationBanner";
import { BrainProvider } from "@/lib/context";
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
import { SideBarProvider } from "@/lib/context/SidebarProvider/sidebar-provider";
import { useSupabase } from "@/lib/context/SupabaseProvider";
import { UpdateMetadata } from "@/lib/helpers/updateMetadata";
import { usePageTracking } from "@/services/analytics/june/usePageTracking";
import "../lib/config/LocaleConfig/i18n";
// This wrapper is used to make effect calls at a high level in app rendering.
const App = ({ children }: PropsWithChildren): JSX.Element => {
const { fetchAllBrains, fetchDefaultBrain, fetchPublicPrompts } =
useBrainContext();
const { session } = useSupabase();
usePageTracking();
useEffect(() => {
if (session?.user) {
void fetchAllBrains();
void fetchDefaultBrain();
void fetchPublicPrompts();
}
}, [session]);
return (
<div className="flex flex-1 flex-col overflow-auto">
<NotificationBanner />
<div className="relative h-full w-full flex justify-stretch items-stretch overflow-auto">
<Menu />
<div className="flex-1">{children}</div>
<UpdateMetadata />
</div>
</div>
);
};
const queryClient = new QueryClient();
const AppWithQueryClient = ({ children }: PropsWithChildren): JSX.Element => {
return (
<QueryClientProvider client={queryClient}>
<BrainProvider>
<SideBarProvider>
<App>{children}</App>
</SideBarProvider>
</BrainProvider>
</QueryClientProvider>
);
};
export { AppWithQueryClient as App };