"use client"; import Link from "next/link"; import { useEffect, useState } from "react"; import { api } from "@/lib/api/client"; import type { components } from "@/lib/api/schema"; import { Card, CardContent } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; type Tree = components["schemas"]["PublicTreeRead"]; // Public directory of trees. The backend returns `public` to everyone and adds // `site_members` trees when the request carries a valid session — so signed-in // users see more here without any client-side branching. export default function ExplorePage() { const [trees, setTrees] = useState([]); const [search, setSearch] = useState(""); const [ready, setReady] = useState(false); useEffect(() => { const q = search.trim(); const t = setTimeout(async () => { const { data } = await api.GET("/api/v1/public/trees", { params: { query: q ? { q } : {} }, }); setTrees(data ?? []); setReady(true); }, 200); return () => clearTimeout(t); }, [search]); return (

Explore public trees

Browse family trees shared on this site. Living people are always hidden.

setSearch(e.target.value)} /> {!ready ? (

Loading…

) : trees.length === 0 ? (

No public trees{search.trim() ? " match that search" : " yet"}.

) : ( )}
); }