From 0c52334fede37e0206b38922808b534733e3c03a Mon Sep 17 00:00:00 2001 From: iMADi-ARCH Date: Tue, 13 Jun 2023 14:04:05 +0530 Subject: [PATCH] feat(brains): temporary /explore/brains route --- frontend/app/explore/DocumentItem/index.tsx | 8 ++-- .../brains/components/BrainListItem.tsx | 40 +++++++++++++++++++ frontend/app/explore/brains/page.tsx | 24 +++++++++++ frontend/app/explore/layout.tsx | 18 +++++++++ 4 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 frontend/app/explore/brains/components/BrainListItem.tsx create mode 100644 frontend/app/explore/brains/page.tsx create mode 100644 frontend/app/explore/layout.tsx diff --git a/frontend/app/explore/DocumentItem/index.tsx b/frontend/app/explore/DocumentItem/index.tsx index f8a2b39e6..f1bea8be5 100644 --- a/frontend/app/explore/DocumentItem/index.tsx +++ b/frontend/app/explore/DocumentItem/index.tsx @@ -3,6 +3,7 @@ import Ellipsis from "@/app/components/ui/Ellipsis"; import { useSupabase } from "@/app/supabase-provider"; import { useToast } from "@/lib/hooks/useToast"; import { useAxios } from "@/lib/useAxios"; +import { motion } from "framer-motion"; import { Dispatch, RefObject, @@ -11,7 +12,6 @@ import { useState, } from "react"; import Button from "../../components/ui/Button"; -import { AnimatedCard } from "../../components/ui/Card"; import Modal from "../../components/ui/Modal"; import { Document } from "../types"; import DocumentData from "./DocumentData"; @@ -45,13 +45,13 @@ const DocumentItem = forwardRef( }; return ( - } - className="flex flex-col sm:flex-row sm:items-center justify-between w-full p-5 gap-5" + className="flex flex-col sm:flex-row sm:items-center justify-between w-full p-5 gap-5 border-b last:border-none border-black/10 dark:border-white/25" > {document.name} @@ -85,7 +85,7 @@ const DocumentItem = forwardRef(

{document.name}

-
+ ); } ); diff --git a/frontend/app/explore/brains/components/BrainListItem.tsx b/frontend/app/explore/brains/components/BrainListItem.tsx new file mode 100644 index 000000000..3a640b764 --- /dev/null +++ b/frontend/app/explore/brains/components/BrainListItem.tsx @@ -0,0 +1,40 @@ +import Button from "@/app/components/ui/Button"; +import Modal from "@/app/components/ui/Modal"; +import { useBrainScope } from "@/lib/context/BrainScopeProvider/hooks/useBrainScope"; +import { BrainScope } from "@/lib/context/BrainScopeProvider/types"; +import { FC } from "react"; +import { FaBrain } from "react-icons/fa"; +import DocumentItem from "../../DocumentItem"; + +interface BrainListItemProps { + brain: BrainScope; +} + +const BrainListItem: FC = ({ brain }) => { + const { removeDocumentFromBrain } = useBrainScope(); + + return ( +
+
+ +
+ {brain.name} + {brain.documents.length} files +
+
+ View} + > +
+ {brain.documents.map((doc) => ( + {}} /> + ))} +
+
+
+ ); +}; + +export default BrainListItem; diff --git a/frontend/app/explore/brains/page.tsx b/frontend/app/explore/brains/page.tsx new file mode 100644 index 000000000..116ef469e --- /dev/null +++ b/frontend/app/explore/brains/page.tsx @@ -0,0 +1,24 @@ +"use client"; +import PageHeading from "@/app/components/ui/PageHeading"; +import { useBrainScope } from "@/lib/context/BrainScopeProvider/hooks/useBrainScope"; +import { FC } from "react"; +import BrainListItem from "./components/BrainListItem"; + +interface BrainsPageProps {} + +const BrainsPage: FC = ({}) => { + const { allBrains } = useBrainScope(); + return ( +
+
+ + {allBrains.map((brain) => { + return ; + })} +
+
+
+ ); +}; + +export default BrainsPage; diff --git a/frontend/app/explore/layout.tsx b/frontend/app/explore/layout.tsx new file mode 100644 index 000000000..ae0c9b580 --- /dev/null +++ b/frontend/app/explore/layout.tsx @@ -0,0 +1,18 @@ +"use client"; +import { redirect } from "next/navigation"; +import { FC, ReactNode } from "react"; +import { useSupabase } from "../supabase-provider"; + +interface LayoutProps { + children?: ReactNode; +} + +const Layout: FC = ({ children }) => { + const { session } = useSupabase(); + if (!session) { + redirect("/login"); + } + return <>{children}; +}; + +export default Layout;