Makes a generic document form

This commit is contained in:
2025-05-31 17:37:38 -07:00
parent 6b6636d695
commit 81fd84790b
5 changed files with 55 additions and 25 deletions

View File

@@ -0,0 +1,28 @@
import { RelationshipType, type CampaignId, type Document } from "@/lib/types";
import { SecretForm } from "./secret/SecretForm";
function assertUnreachable(_x: never): never {
throw new Error("DocumentForm switch is not exhaustive");
}
/**
* Renders a form for any document type depending on the relationship.
*/
export const DocumentForm = ({
campaignId,
relationshipType,
onCreate,
}: {
campaignId: CampaignId;
relationshipType: RelationshipType;
onCreate: (document: Document) => Promise<void>;
}) => {
switch (relationshipType) {
case RelationshipType.Secrets:
return <SecretForm campaign={campaignId} onCreate={onCreate} />;
case RelationshipType.DiscoveredIn:
return "Form not supported here";
}
return assertUnreachable(relationshipType);
};