"use client"; import { useState, useEffect } from "react"; import axios from "axios"; 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"; import { AnimatePresence } from "framer-motion"; 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` ); const response = await axios.get<{ documents: Document[] }>( `${process.env.NEXT_PUBLIC_BACKEND_URL}/explore` ); setDocuments(response.data.documents); } catch (error) { console.error("Error fetching documents", error); setDocuments([]); } setIsPending(false); }; return (

Explore Your Brain

View what’s in your second brain

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

Oh No, Your Brain is empty.

)}
)}
); }