quivr/frontend/app/search/page.tsx

83 lines
2.7 KiB
TypeScript
Raw Normal View History

"use client";
import { usePathname } from "next/navigation";
import { useEffect } from "react";
import { QuivrLogo } from "@/lib/assets/QuivrLogo";
import { AddBrainModal } from "@/lib/components/AddBrainModal";
import { useBrainCreationContext } from "@/lib/components/AddBrainModal/components/AddBrainSteps/brainCreation-provider";
import PageHeader from "@/lib/components/PageHeader/PageHeader";
import { UploadDocumentModal } from "@/lib/components/UploadDocumentModal/UploadDocumentModal";
import { SearchBar } from "@/lib/components/ui/SearchBar/SearchBar";
import { useKnowledgeToFeedContext } from "@/lib/context/KnowledgeToFeedProvider/hooks/useKnowledgeToFeedContext";
import { useSupabase } from "@/lib/context/SupabaseProvider";
import { redirectToLogin } from "@/lib/router/redirectToLogin";
import { ButtonType } from "@/lib/types/QuivrButton";
import styles from "./page.module.scss";
const Search = (): JSX.Element => {
const pathname = usePathname();
const { session } = useSupabase();
const { setShouldDisplayFeedCard } = useKnowledgeToFeedContext();
const { setIsBrainCreationModalOpened } = useBrainCreationContext();
useEffect(() => {
if (session === null) {
redirectToLogin();
}
2024-01-31 00:34:32 +03:00
}, [pathname, session]);
const buttons: ButtonType[] = [
{
label: "Create brain",
color: "primary",
onClick: () => {
setIsBrainCreationModalOpened(true);
},
},
{
label: "Add knowledge",
color: "primary",
onClick: () => {
setShouldDisplayFeedCard(true);
},
},
];
return (
<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="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 />
</div>
</div>
<div className={styles.shortcuts_card_wrapper}>
<div className={styles.shortcut_wrapper}>
<span className={styles.shortcut}>@</span>
<span>Select a brain</span>
</div>
<div className={styles.shortcut_wrapper}>
<span className={styles.shortcut}>#</span>
<span>Select a prompt</span>
</div>
</div>
</div>
<UploadDocumentModal />
<AddBrainModal />
</div>
);
};
export default Search;