Files
dm-companion/src/components/documents/RelatedDocumentList.tsx

30 lines
728 B
TypeScript

import { useDocument, useDocumentCache } from "@/context/document/hooks";
import type { DocumentId, RelationshipType } from "@/lib/types";
import { RelationshipList } from "../RelationshipList";
import { Loader } from "../Loader";
export type Props = {
documentId: DocumentId;
relationshipType: RelationshipType;
};
export function RelatedDocumentList({ documentId, relationshipType }: Props) {
const { docResult } = useDocument(documentId);
const { cache } = useDocumentCache();
if (docResult?.type !== "ready") {
return <Loader />;
}
const doc = docResult.value.doc;
return (
<RelationshipList
key={relationshipType}
root={doc}
relationshipType={relationshipType}
/>
);
}