34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
// DocumentRow.tsx
|
|
// Generic row component for displaying any document type.
|
|
import { type AnyDocument } from "@/lib/types";
|
|
import { LocationPrintRow } from "./location/LocationPrintRow";
|
|
import { MonsterPrintRow } from "./monsters/MonsterPrintRow";
|
|
import { NpcPrintRow } from "./npc/NpcPrintRow";
|
|
import { ScenePrintRow } from "./scene/ScenePrintRow";
|
|
import { SecretPrintRow } from "./secret/SecretPrintRow";
|
|
import { SessionPrintRow } from "./session/SessionPrintRow";
|
|
import { TreasurePrintRow } from "./treasure/TreasurePrintRow";
|
|
|
|
/**
|
|
* 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 DocumentPrintRow = ({ document }: { document: AnyDocument }) => {
|
|
switch (document.type) {
|
|
case "location":
|
|
return <LocationPrintRow location={document} />;
|
|
case "monster":
|
|
return <MonsterPrintRow monster={document} />;
|
|
case "npc":
|
|
return <NpcPrintRow npc={document} />;
|
|
case "scene":
|
|
return <ScenePrintRow scene={document} />;
|
|
case "secret":
|
|
return <SecretPrintRow secret={document} />;
|
|
case "session":
|
|
return <SessionPrintRow session={document} />;
|
|
case "treasure":
|
|
return <TreasurePrintRow treasure={document} />;
|
|
}
|
|
};
|