"use client"; import { usePathname } from "next/navigation"; import { useEffect, useState } from "react"; import { QuivrLogo } from "@/lib/assets/QuivrLogo"; import { AddBrainModal } from "@/lib/components/AddBrainModal"; import { useBrainCreationContext } from "@/lib/components/AddBrainModal/brainCreation-provider"; import { OnboardingModal } from "@/lib/components/OnboardingModal/OnboardingModal"; import PageHeader from "@/lib/components/PageHeader/PageHeader"; import { UploadDocumentModal } from "@/lib/components/UploadDocumentModal/UploadDocumentModal"; import { MessageInfoBox } from "@/lib/components/ui/MessageInfoBox/MessageInfoBox"; import QuivrButton from "@/lib/components/ui/QuivrButton/QuivrButton"; import { SearchBar } from "@/lib/components/ui/SearchBar/SearchBar"; import { useOnboardingContext } from "@/lib/context/OnboardingProvider/hooks/useOnboardingContext"; import { useSupabase } from "@/lib/context/SupabaseProvider"; import { useUserSettingsContext } from "@/lib/context/UserSettingsProvider/hooks/useUserSettingsContext"; import { useUserData } from "@/lib/hooks/useUserData"; import { redirectToLogin } from "@/lib/router/redirectToLogin"; import { ButtonType } from "@/lib/types/QuivrButton"; import styles from "./page.module.scss"; const Search = (): JSX.Element => { const [isUserDataFetched, setIsUserDataFetched] = useState(false); const pathname = usePathname(); const { session } = useSupabase(); const { isBrainCreationModalOpened, setIsBrainCreationModalOpened } = useBrainCreationContext(); const { userIdentityData } = useUserData(); const { isDarkMode } = useUserSettingsContext(); const { isBrainCreated } = useOnboardingContext(); useEffect(() => { if (userIdentityData) { setIsUserDataFetched(true); } }, [userIdentityData]); useEffect(() => { if (session === null) { redirectToLogin(); } }, [pathname, session]); const buttons: ButtonType[] = [ { label: "Create brain", color: "primary", onClick: () => { setIsBrainCreationModalOpened(true); }, iconName: "brain", }, ]; return ( <>