Revert "Start supporting edit forms for any document type."
This reverts commit 6845bd06bf.
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
import { RelationshipType, type CampaignId, type Document } from "@/lib/types";
|
||||
import { LocationForm } from "./location/LocationForm";
|
||||
import { MonsterForm } from "./monsters/MonsterForm";
|
||||
import { NpcForm } from "./npc/NpcForm";
|
||||
import { SceneForm } from "./scene/SceneForm";
|
||||
import { SecretForm } from "./secret/SecretForm";
|
||||
import { TreasureForm } from "./treasure/TreasureForm";
|
||||
|
||||
function assertUnreachable(_x: never): never {
|
||||
throw new Error("NewRelatedDocumentForm switch is not exhaustive");
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a form for any document type depending on the relationship.
|
||||
*/
|
||||
export const NewRelatedDocumentForm = ({
|
||||
campaignId,
|
||||
relationshipType,
|
||||
onCreate,
|
||||
}: {
|
||||
campaignId: CampaignId;
|
||||
relationshipType: RelationshipType;
|
||||
onCreate: (document: Document) => Promise<void>;
|
||||
}) => {
|
||||
switch (relationshipType) {
|
||||
case RelationshipType.Locations:
|
||||
return (
|
||||
<LocationForm
|
||||
target={{
|
||||
type: "new",
|
||||
campaignId,
|
||||
}}
|
||||
onSubmit={onCreate}
|
||||
/>
|
||||
);
|
||||
case RelationshipType.Monsters:
|
||||
return <MonsterForm campaign={campaignId} onCreate={onCreate} />;
|
||||
case RelationshipType.Npcs:
|
||||
return <NpcForm campaign={campaignId} onCreate={onCreate} />;
|
||||
case RelationshipType.Secrets:
|
||||
return <SecretForm campaign={campaignId} onCreate={onCreate} />;
|
||||
case RelationshipType.Treasures:
|
||||
return <TreasureForm campaign={campaignId} onCreate={onCreate} />;
|
||||
case RelationshipType.Scenes:
|
||||
return <SceneForm campaign={campaignId} onCreate={onCreate} />;
|
||||
case RelationshipType.DiscoveredIn:
|
||||
return "Form not supported here";
|
||||
}
|
||||
|
||||
return assertUnreachable(relationshipType);
|
||||
};
|
||||
Reference in New Issue
Block a user