diff --git a/frontend/app/explore/page.tsx b/frontend/app/explore/page.tsx index 3378f56b4..19659c9e9 100644 --- a/frontend/app/explore/page.tsx +++ b/frontend/app/explore/page.tsx @@ -5,15 +5,18 @@ import DocumentItem from "./DocumentItem"; import { Document } from "./types"; import Button from "../components/ui/Button"; import Link from "next/link"; +import Spinner from "../components/ui/Spinner"; export default function ExplorePage() { const [documents, setDocuments] = useState([]); + const [isPending, setIsPending] = useState(true); useEffect(() => { fetchDocuments(); }, []); const fetchDocuments = async () => { + setIsPending(true); try { console.log( `Fetching documents from ${process.env.NEXT_PUBLIC_BACKEND_URL}/explore` @@ -26,6 +29,7 @@ export default function ExplorePage() { console.error("Error fetching documents", error); setDocuments([]); } + setIsPending(false); }; return ( @@ -34,24 +38,28 @@ export default function ExplorePage() {

Explore Your Brain

View what’s in your second brain

-
- {documents.length !== 0 ? ( - documents.map((document, index) => ( - - )) - ) : ( -
-

Oh No, Your Brain is empty.

- - - -
- )} -
+ {isPending ? ( + + ) : ( +
+ {documents.length !== 0 ? ( + documents.map((document, index) => ( + + )) + ) : ( +
+

Oh No, Your Brain is empty.

+ + + +
+ )} +
+ )} ); }