Makes a generic document row
This commit is contained in:
35
src/components/documents/DocumentRow.tsx
Normal file
35
src/components/documents/DocumentRow.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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, type Document, type Session } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* 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 <SessionRow session={document} />;
|
||||
}
|
||||
if (isSecret(document)) {
|
||||
return <SecretRow secret={document} session={session} />;
|
||||
}
|
||||
// Fallback: show ID and creation time
|
||||
return (
|
||||
<div>
|
||||
<div className="font-semibold text-lg text-slate-300">
|
||||
Unrecognized Document
|
||||
</div>
|
||||
<div className="text-slate-400 text-sm">ID: {document.id}</div>
|
||||
<div className="text-slate-400 text-sm">Created: {document.created}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user