2024-01-20 07:34:30 +03:00
|
|
|
"use client";
|
|
|
|
import { usePathname } from "next/navigation";
|
2024-04-09 19:30:05 +03:00
|
|
|
import { useLayoutEffect, useState } from "react";
|
2024-01-20 07:34:30 +03:00
|
|
|
|
|
|
|
import { QuivrLogo } from "@/lib/assets/QuivrLogo";
|
2024-02-07 03:05:07 +03:00
|
|
|
import { AddBrainModal } from "@/lib/components/AddBrainModal";
|
2024-02-15 03:37:33 +03:00
|
|
|
import { useBrainCreationContext } from "@/lib/components/AddBrainModal/brainCreation-provider";
|
2024-03-21 22:10:54 +03:00
|
|
|
import { OnboardingModal } from "@/lib/components/OnboardingModal/OnboardingModal";
|
2024-02-07 03:05:07 +03:00
|
|
|
import PageHeader from "@/lib/components/PageHeader/PageHeader";
|
|
|
|
import { UploadDocumentModal } from "@/lib/components/UploadDocumentModal/UploadDocumentModal";
|
2024-04-09 19:06:33 +03:00
|
|
|
import { MessageInfoBox } from "@/lib/components/ui/MessageInfoBox/MessageInfoBox";
|
|
|
|
import QuivrButton from "@/lib/components/ui/QuivrButton/QuivrButton";
|
2024-01-20 07:34:30 +03:00
|
|
|
import { SearchBar } from "@/lib/components/ui/SearchBar/SearchBar";
|
2024-01-20 23:04:03 +03:00
|
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
2024-03-21 10:01:21 +03:00
|
|
|
import { useUserSettingsContext } from "@/lib/context/UserSettingsProvider/hooks/useUserSettingsContext";
|
2024-04-09 19:06:33 +03:00
|
|
|
import { useUserData } from "@/lib/hooks/useUserData";
|
2024-01-20 23:04:03 +03:00
|
|
|
import { redirectToLogin } from "@/lib/router/redirectToLogin";
|
2024-02-07 03:05:07 +03:00
|
|
|
import { ButtonType } from "@/lib/types/QuivrButton";
|
2024-01-20 07:34:30 +03:00
|
|
|
|
|
|
|
import styles from "./page.module.scss";
|
|
|
|
|
|
|
|
const Search = (): JSX.Element => {
|
2024-04-09 19:30:05 +03:00
|
|
|
const [isPageLoaded, setIsPageLoaded] = useState<boolean>(false);
|
2024-01-23 04:37:45 +03:00
|
|
|
const pathname = usePathname();
|
|
|
|
const { session } = useSupabase();
|
2024-04-09 19:06:33 +03:00
|
|
|
const { isBrainCreationModalOpened, setIsBrainCreationModalOpened } =
|
|
|
|
useBrainCreationContext();
|
|
|
|
const { userIdentityData } = useUserData();
|
2024-03-21 10:01:21 +03:00
|
|
|
const { isDarkMode } = useUserSettingsContext();
|
2024-01-23 04:37:45 +03:00
|
|
|
|
2024-04-09 19:30:05 +03:00
|
|
|
useLayoutEffect(() => {
|
2024-01-23 04:37:45 +03:00
|
|
|
if (session === null) {
|
|
|
|
redirectToLogin();
|
2024-04-09 19:30:05 +03:00
|
|
|
} else {
|
|
|
|
setTimeout(() => setIsPageLoaded(true), 1000);
|
2024-01-23 04:37:45 +03:00
|
|
|
}
|
2024-01-31 00:34:32 +03:00
|
|
|
}, [pathname, session]);
|
2024-01-23 04:37:45 +03:00
|
|
|
|
2024-02-07 03:05:07 +03:00
|
|
|
const buttons: ButtonType[] = [
|
|
|
|
{
|
|
|
|
label: "Create brain",
|
|
|
|
color: "primary",
|
|
|
|
onClick: () => {
|
|
|
|
setIsBrainCreationModalOpened(true);
|
|
|
|
},
|
2024-02-07 10:34:50 +03:00
|
|
|
iconName: "brain",
|
2024-02-07 03:05:07 +03:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2024-01-23 04:37:45 +03:00
|
|
|
return (
|
2024-04-09 19:06:33 +03:00
|
|
|
<>
|
|
|
|
<div className={styles.main_container}>
|
|
|
|
<div className={styles.page_header}>
|
|
|
|
<PageHeader iconName="home" label="Home" buttons={buttons} />
|
|
|
|
</div>
|
|
|
|
<div className={styles.search_page_container}>
|
|
|
|
<div className={styles.main_wrapper}>
|
|
|
|
<div className={styles.quivr_logo_wrapper}>
|
|
|
|
<QuivrLogo size={80} color={isDarkMode ? "white" : "black"} />
|
|
|
|
<div className={styles.quivr_text}>
|
|
|
|
<span>Talk to </span>
|
|
|
|
<span className={styles.quivr_text_primary}>Quivr</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={styles.search_bar_wrapper}>
|
|
|
|
<SearchBar />
|
2024-02-07 03:05:07 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-09 19:06:33 +03:00
|
|
|
<div className={styles.shortcuts_card_wrapper}>
|
|
|
|
<div className={styles.shortcut_wrapper}>
|
|
|
|
<span>Press</span>
|
|
|
|
<span className={styles.shortcut}>@</span>
|
|
|
|
<span>to select a brain</span>
|
|
|
|
</div>
|
2024-02-07 03:05:07 +03:00
|
|
|
</div>
|
2024-02-02 22:50:09 +03:00
|
|
|
</div>
|
2024-04-09 19:06:33 +03:00
|
|
|
<UploadDocumentModal />
|
|
|
|
<AddBrainModal />
|
|
|
|
<OnboardingModal />
|
|
|
|
</div>
|
2024-04-09 19:30:05 +03:00
|
|
|
{!isBrainCreationModalOpened &&
|
|
|
|
!userIdentityData?.onboarded &&
|
|
|
|
!!isPageLoaded && (
|
|
|
|
<div className={styles.onboarding_overlay}>
|
|
|
|
<div className={styles.first_brain_button}>
|
|
|
|
<MessageInfoBox type="tutorial">
|
|
|
|
<span>
|
|
|
|
Press the following button to create your first brain
|
|
|
|
</span>
|
|
|
|
</MessageInfoBox>
|
|
|
|
<QuivrButton
|
|
|
|
iconName="brain"
|
|
|
|
label="Create Brain"
|
|
|
|
color="primary"
|
|
|
|
onClick={() => {
|
|
|
|
setIsBrainCreationModalOpened(true);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2024-02-07 03:05:07 +03:00
|
|
|
</div>
|
2024-04-09 19:30:05 +03:00
|
|
|
)}
|
2024-04-09 19:06:33 +03:00
|
|
|
</>
|
2024-01-23 04:37:45 +03:00
|
|
|
);
|
2024-01-20 07:34:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Search;
|