// DocumentRow.tsx // Generic row component for displaying any document type. import { SessionRow } from "@/components/documents/session/SessionRow"; import { SecretRow } from "@/components/documents/secret/SecretRow"; import { isSecret, isSession, isTreasure, type Document, type Session, } from "@/lib/types"; import { TreasureRow } from "./treasure/TreasureRow"; /** * Renders a row for any document type. Prioritizes Session, then Secret, then falls back to ID and creation time. * If rendering a SecretRow, uses the provided session prop if available. */ export const DocumentRow = ({ document, session, }: { document: Document; session?: Session; }) => { if (isSession(document)) { // Use SessionRow for session documents return ; } if (isSecret(document)) { return ; } if (isTreasure(document)) { return ; } // Fallback: show ID and creation time return (
Unrecognized Document
ID: {document.id}
Created: {document.created}
); };