I think I have a working document cache solution that's actually pretty good.
This commit is contained in:
@@ -1,31 +1,43 @@
|
||||
import { RelationshipList } from "@/components/RelationshipList";
|
||||
import { DocumentEditForm } from "@/components/documents/DocumentEditForm";
|
||||
import { useDocument } from "@/context/document/DocumentContext";
|
||||
import { useDocument } from "@/context/document/hooks";
|
||||
import { displayName, relationshipsForDocument } from "@/lib/relationships";
|
||||
import { Tab, TabGroup, TabList, TabPanel, TabPanels } from "@headlessui/react";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { Loader } from "../Loader";
|
||||
import type { DocumentId } from "@/lib/types";
|
||||
|
||||
export function DocumentView() {
|
||||
const { state } = useDocument();
|
||||
export function DocumentView({ documentId }: { documentId: DocumentId }) {
|
||||
const { docResult } = useDocument(documentId);
|
||||
|
||||
if (state.status === "loading") {
|
||||
console.info(`Rendering document: `, docResult);
|
||||
|
||||
if (docResult?.type !== "ready") {
|
||||
return <Loader />;
|
||||
}
|
||||
|
||||
const doc = state.doc;
|
||||
const doc = docResult.value.doc;
|
||||
|
||||
const relationshipList = relationshipsForDocument(doc);
|
||||
|
||||
return (
|
||||
<div key={doc.id} className="max-w-xl mx-auto py-2 px-4">
|
||||
<Link
|
||||
to="/document/$documentId/print"
|
||||
params={{ documentId: doc.id }}
|
||||
className="text-slate-400 hover:text-violet-400 text-sm underline underline-offset-2 transition-colors mb-4"
|
||||
>
|
||||
Print
|
||||
</Link>
|
||||
<div>
|
||||
<Link
|
||||
to="/document/$documentId/print"
|
||||
params={{ documentId: doc.id }}
|
||||
className="text-slate-400 hover:text-violet-400 text-sm underline underline-offset-2 transition-colors mb-4"
|
||||
>
|
||||
Back to campaign
|
||||
</Link>
|
||||
<Link
|
||||
to="/document/$documentId/print"
|
||||
params={{ documentId: doc.id }}
|
||||
className="text-slate-400 hover:text-violet-400 text-sm underline underline-offset-2 transition-colors mb-4"
|
||||
>
|
||||
Print
|
||||
</Link>
|
||||
</div>
|
||||
<DocumentEditForm document={doc} />
|
||||
<TabGroup>
|
||||
<TabList className="flex flex-row flex-wrap gap-1 mt-2">
|
||||
|
||||
Reference in New Issue
Block a user