import {
  RelationshipType,
  type CampaignId,
  type AnyDocument,
} from "@/lib/types";
import { NewLocationForm } from "./location/NewLocationForm";
import { NewMonsterForm } from "./monsters/NewMonsterForm";
import { NewNpcForm } from "./npc/NewNpcForm";
import { NewSceneForm } from "./scene/NewSceneForm";
import { NewSecretForm } from "./secret/NewSecretForm";
import { NewTreasureForm } from "./treasure/NewTreasureForm";

/**
 * Renders a form for any document type depending on the relationship.
 */
export const NewRelatedDocumentForm = ({
  campaignId,
  relationshipType,
  onCreate,
}: {
  campaignId: CampaignId;
  relationshipType: RelationshipType;
  onCreate: (doc: AnyDocument) => Promise<void>;
}) => {
  switch (relationshipType) {
    case RelationshipType.Locations:
      return <NewLocationForm campaign={campaignId} onCreate={onCreate} />;
    case RelationshipType.Monsters:
      return <NewMonsterForm campaign={campaignId} onCreate={onCreate} />;
    case RelationshipType.Npcs:
      return <NewNpcForm campaign={campaignId} onCreate={onCreate} />;
    case RelationshipType.Secrets:
      return <NewSecretForm campaign={campaignId} onCreate={onCreate} />;
    case RelationshipType.Treasures:
      return <NewTreasureForm campaign={campaignId} onCreate={onCreate} />;
    case RelationshipType.Scenes:
      return <NewSceneForm campaign={campaignId} onCreate={onCreate} />;
    case RelationshipType.DiscoveredIn:
      return "Form not supported here";
  }
};
