Adds a title to the document page.
This commit is contained in:
25
src/components/documents/DocumentTitle.tsx
Normal file
25
src/components/documents/DocumentTitle.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { type AnyDocument, type Session } from "@/lib/types";
|
||||
import { FormattedDate } from "../FormattedDate";
|
||||
|
||||
/**
|
||||
* Renders the document title to go at the top a document page.
|
||||
*/
|
||||
export const DocumentTitle = ({
|
||||
document,
|
||||
session,
|
||||
}: {
|
||||
document: AnyDocument;
|
||||
session?: Session;
|
||||
}) => {
|
||||
switch (document.type) {
|
||||
case "session":
|
||||
return (
|
||||
<h1>
|
||||
<FormattedDate date={document.created} />
|
||||
</h1>
|
||||
);
|
||||
|
||||
default:
|
||||
return <h1>document.type</h1>;
|
||||
}
|
||||
};
|
||||
@@ -7,6 +7,7 @@ import { Link } from "@tanstack/react-router";
|
||||
import * as _ from "lodash";
|
||||
import { Loader } from "../Loader";
|
||||
import { Route as RelationshipRoute } from "@/routes/_app/_authenticated/document.$documentId/$relationshipType";
|
||||
import { DocumentTitle } from "./DocumentTitle";
|
||||
|
||||
export function DocumentView({ documentId }: { documentId: DocumentId }) {
|
||||
const { docResult } = useDocument(documentId);
|
||||
@@ -27,6 +28,7 @@ export function DocumentView({ documentId }: { documentId: DocumentId }) {
|
||||
|
||||
return (
|
||||
<div key={doc.id} className="max-w-xl mx-auto py-2 px-4">
|
||||
<DocumentTitle document={doc} />
|
||||
<div>
|
||||
<Link
|
||||
to={CampaignRoute.to}
|
||||
|
||||
Reference in New Issue
Block a user