Renames forms to make clear if they are new or edit
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import { RelationshipType, type CampaignId, type Document } from "@/lib/types";
|
import { RelationshipType, type CampaignId, type Document } from "@/lib/types";
|
||||||
import { LocationForm } from "./location/LocationForm";
|
import { NewLocationForm } from "./location/NewLocationForm";
|
||||||
import { MonsterForm } from "./monsters/MonsterForm";
|
import { NewMonsterForm } from "./monsters/NewMonsterForm";
|
||||||
import { NpcForm } from "./npc/NpcForm";
|
import { NewNpcForm } from "./npc/NewNpcForm";
|
||||||
import { SceneForm } from "./scene/SceneForm";
|
import { NewSceneForm } from "./scene/NewSceneForm";
|
||||||
import { SecretForm } from "./secret/SecretForm";
|
import { NewSecretForm } from "./secret/NewSecretForm";
|
||||||
import { TreasureForm } from "./treasure/TreasureForm";
|
import { NewTreasureForm } from "./treasure/NewTreasureForm";
|
||||||
|
|
||||||
function assertUnreachable(_x: never): never {
|
function assertUnreachable(_x: never): never {
|
||||||
throw new Error("DocumentForm switch is not exhaustive");
|
throw new Error("DocumentForm switch is not exhaustive");
|
||||||
@@ -24,19 +24,19 @@ export const NewRelatedDocumentForm = ({
|
|||||||
}) => {
|
}) => {
|
||||||
switch (relationshipType) {
|
switch (relationshipType) {
|
||||||
case RelationshipType.Locations:
|
case RelationshipType.Locations:
|
||||||
return <LocationForm campaign={campaignId} onCreate={onCreate} />;
|
return <NewLocationForm campaign={campaignId} onCreate={onCreate} />;
|
||||||
case RelationshipType.Monsters:
|
case RelationshipType.Monsters:
|
||||||
return <MonsterForm campaign={campaignId} onCreate={onCreate} />;
|
return <NewMonsterForm campaign={campaignId} onCreate={onCreate} />;
|
||||||
case RelationshipType.Npcs:
|
case RelationshipType.Npcs:
|
||||||
return <NpcForm campaign={campaignId} onCreate={onCreate} />;
|
return <NewNpcForm campaign={campaignId} onCreate={onCreate} />;
|
||||||
case RelationshipType.Secrets:
|
case RelationshipType.Secrets:
|
||||||
return <SecretForm campaign={campaignId} onCreate={onCreate} />;
|
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:
|
case RelationshipType.DiscoveredIn:
|
||||||
return "Form not supported here";
|
return "Form not supported here";
|
||||||
case RelationshipType.Treasures:
|
|
||||||
return <TreasureForm campaign={campaignId} onCreate={onCreate} />;
|
|
||||||
case RelationshipType.Scenes:
|
|
||||||
return <SceneForm campaign={campaignId} onCreate={onCreate} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return assertUnreachable(relationshipType);
|
return assertUnreachable(relationshipType);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { pb } from "@/lib/pocketbase";
|
|||||||
/**
|
/**
|
||||||
* Renders a form to add a new location. Calls onCreate with the new location document.
|
* Renders a form to add a new location. Calls onCreate with the new location document.
|
||||||
*/
|
*/
|
||||||
export const LocationForm = ({
|
export const NewLocationForm = ({
|
||||||
campaign,
|
campaign,
|
||||||
onCreate,
|
onCreate,
|
||||||
}: {
|
}: {
|
||||||
@@ -5,7 +5,7 @@ import { pb } from "@/lib/pocketbase";
|
|||||||
/**
|
/**
|
||||||
* Renders a form to add a new monster. Calls onCreate with the new monster document.
|
* Renders a form to add a new monster. Calls onCreate with the new monster document.
|
||||||
*/
|
*/
|
||||||
export const MonsterForm = ({
|
export const NewMonsterForm = ({
|
||||||
campaign,
|
campaign,
|
||||||
onCreate,
|
onCreate,
|
||||||
}: {
|
}: {
|
||||||
@@ -5,7 +5,7 @@ import { pb } from "@/lib/pocketbase";
|
|||||||
/**
|
/**
|
||||||
* Renders a form to add a new npc. Calls onCreate with the new npc document.
|
* Renders a form to add a new npc. Calls onCreate with the new npc document.
|
||||||
*/
|
*/
|
||||||
export const NpcForm = ({
|
export const NewNpcForm = ({
|
||||||
campaign,
|
campaign,
|
||||||
onCreate,
|
onCreate,
|
||||||
}: {
|
}: {
|
||||||
@@ -7,7 +7,7 @@ import { pb } from "@/lib/pocketbase";
|
|||||||
/**
|
/**
|
||||||
* Renders a form to add a new scene. Calls onCreate with the new scene document.
|
* Renders a form to add a new scene. Calls onCreate with the new scene document.
|
||||||
*/
|
*/
|
||||||
export const SceneForm = ({
|
export const NewSceneForm = ({
|
||||||
campaign,
|
campaign,
|
||||||
onCreate,
|
onCreate,
|
||||||
}: {
|
}: {
|
||||||
@@ -7,7 +7,7 @@ import { pb } from "@/lib/pocketbase";
|
|||||||
/**
|
/**
|
||||||
* Renders a form to add a new secret. Calls onCreate with the new secret document.
|
* Renders a form to add a new secret. Calls onCreate with the new secret document.
|
||||||
*/
|
*/
|
||||||
export const SecretForm = ({
|
export const NewSecretForm = ({
|
||||||
campaign,
|
campaign,
|
||||||
onCreate,
|
onCreate,
|
||||||
}: {
|
}: {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AutoSaveTextarea } from "@/components/AutoSaveTextarea";
|
import { AutoSaveTextarea } from "@/components/AutoSaveTextarea";
|
||||||
import type { Session } from "@/lib/types";
|
import type { Session } from "@/lib/types";
|
||||||
|
|
||||||
export const SessionForm = ({
|
export const EditSessionForm = ({
|
||||||
session,
|
session,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
}: {
|
}: {
|
||||||
@@ -7,7 +7,7 @@ import { pb } from "@/lib/pocketbase";
|
|||||||
/**
|
/**
|
||||||
* Renders a form to add a new treasure. Calls onCreate with the new treasure document.
|
* Renders a form to add a new treasure. Calls onCreate with the new treasure document.
|
||||||
*/
|
*/
|
||||||
export const TreasureForm = ({
|
export const NewTreasureForm = ({
|
||||||
campaign,
|
campaign,
|
||||||
onCreate,
|
onCreate,
|
||||||
}: {
|
}: {
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
type Document,
|
type Document,
|
||||||
} from "@/lib/types";
|
} from "@/lib/types";
|
||||||
import { RelationshipList } from "@/components/RelationshipList";
|
import { RelationshipList } from "@/components/RelationshipList";
|
||||||
import { SessionForm } from "@/components/documents/session/SessionForm";
|
import { EditSessionForm } from "@/components/documents/session/EditSessionForm";
|
||||||
|
|
||||||
export const Route = createFileRoute(
|
export const Route = createFileRoute(
|
||||||
"/_app/_authenticated/document/$documentId",
|
"/_app/_authenticated/document/$documentId",
|
||||||
@@ -56,7 +56,10 @@ function RouteComponent() {
|
|||||||
>
|
>
|
||||||
Print
|
Print
|
||||||
</Link>
|
</Link>
|
||||||
<SessionForm session={session as Session} onSubmit={handleSaveSession} />
|
<EditSessionForm
|
||||||
|
session={session as Session}
|
||||||
|
onSubmit={handleSaveSession}
|
||||||
|
/>
|
||||||
{[
|
{[
|
||||||
RelationshipType.Scenes,
|
RelationshipType.Scenes,
|
||||||
RelationshipType.Secrets,
|
RelationshipType.Secrets,
|
||||||
|
|||||||
Reference in New Issue
Block a user