import { useEffect, useMemo, useState } from "react"; import { useParams } from "react-router-dom"; import { api, type Entity, type PortalDocument, type User } from "../api"; import { categoryLabel, formatDate } from "../format"; import EntityHeader from "../components/EntityHeader"; export default function EntityDocuments() { const { id } = useParams<{ id: string }>(); const [entity, setEntity] = useState(null); const [docs, setDocs] = useState([]); const [users, setUsers] = useState([]); const [error, setError] = useState(""); const [loading, setLoading] = useState(true); const userById = useMemo(() => new Map(users.map((u) => [u.id, u])), [users]); const loadDocs = (eid: number) => api.listDocuments({ entity_id: eid }).then(setDocs).catch((e) => setError(e.message)); useEffect(() => { if (!id) return; const eid = parseInt(id); api.getEntity(eid).then(setEntity).catch((e) => setError(e.message)); api.listUsers().then(setUsers).catch(() => {}); loadDocs(eid).finally(() => setLoading(false)); }, [id]); if (loading || !entity) return
Loading…
; const eid = entity.id!; return (
{error &&

{error}

}

All documents for this fund. As admin you see everything; each investor only sees documents shared to the fund or addressed to them. Upload from the Documents admin screen.

{docs.map((d) => ( ))} {docs.length === 0 && ( )}
Title Category Visibility Uploaded
{d.title} {categoryLabel(d.category)} {d.investor_user_id == null ? "Shared (all investors)" : `Private · ${userById.get(d.investor_user_id)?.name ?? d.investor_user_id}`} {formatDate(d.created_at)} Download
No documents for this fund yet.
); }