diff --git a/src/components/documents/location/NewLocationForm.tsx b/src/components/documents/location/NewLocationForm.tsx
index a9021df..d6c1f6d 100644
--- a/src/components/documents/location/NewLocationForm.tsx
+++ b/src/components/documents/location/NewLocationForm.tsx
@@ -1,6 +1,9 @@
import { useState } from "react";
import type { CampaignId, Location } from "@/lib/types";
import { pb } from "@/lib/pocketbase";
+import { BaseForm } from "@/components/form/BaseForm";
+import { MultiLineInput } from "@/components/form/MultiLineInput";
+import { SingleLineInput } from "@/components/form/SingleLineInput";
/**
* Renders a form to add a new location. Calls onCreate with the new location document.
@@ -42,42 +45,29 @@ export const NewLocationForm = ({
}
return (
-
+ isLoading={adding || !name.trim()}
+ error={error}
+ content={
+ <>
+
+
+ >
+ }
+ />
);
};
diff --git a/src/components/documents/monsters/NewMonsterForm.tsx b/src/components/documents/monsters/NewMonsterForm.tsx
index 893f382..09a638f 100644
--- a/src/components/documents/monsters/NewMonsterForm.tsx
+++ b/src/components/documents/monsters/NewMonsterForm.tsx
@@ -1,6 +1,8 @@
import { useState } from "react";
import type { CampaignId, Monster } from "@/lib/types";
import { pb } from "@/lib/pocketbase";
+import { BaseForm } from "@/components/form/BaseForm";
+import { SingleLineInput } from "@/components/form/SingleLineInput";
/**
* Renders a form to add a new monster. Calls onCreate with the new monster document.
@@ -13,7 +15,6 @@ export const NewMonsterForm = ({
onCreate: (monster: Monster) => Promise;
}) => {
const [name, setName] = useState("");
- const [description, setDescription] = useState("");
const [adding, setAdding] = useState(false);
const [error, setError] = useState(null);
@@ -28,11 +29,9 @@ export const NewMonsterForm = ({
type: "monster",
data: {
name,
- description,
},
});
setName("");
- setDescription("");
await onCreate(monsterDoc);
} catch (e: any) {
setError(e?.message || "Failed to add monster.");
@@ -42,31 +41,18 @@ export const NewMonsterForm = ({
}
return (
-
+ }
+ />
);
};
diff --git a/src/components/documents/npc/NewNpcForm.tsx b/src/components/documents/npc/NewNpcForm.tsx
index 9c964a0..fa934f5 100644
--- a/src/components/documents/npc/NewNpcForm.tsx
+++ b/src/components/documents/npc/NewNpcForm.tsx
@@ -1,6 +1,9 @@
import { useState } from "react";
import type { CampaignId, Npc } from "@/lib/types";
import { pb } from "@/lib/pocketbase";
+import { BaseForm } from "@/components/form/BaseForm";
+import { SingleLineInput } from "@/components/form/SingleLineInput";
+import { MultiLineInput } from "@/components/form/MultiLineInput";
/**
* Renders a form to add a new npc. Calls onCreate with the new npc document.
@@ -42,42 +45,29 @@ export const NewNpcForm = ({
}
return (
-
+ isLoading={adding}
+ error={error}
+ content={
+ <>
+
+
+ >
+ }
+ />
);
};
diff --git a/src/components/documents/secret/NewSecretForm.tsx b/src/components/documents/secret/NewSecretForm.tsx
index fe6c63f..234182d 100644
--- a/src/components/documents/secret/NewSecretForm.tsx
+++ b/src/components/documents/secret/NewSecretForm.tsx
@@ -3,6 +3,8 @@
import { useState } from "react";
import type { CampaignId, Secret } from "@/lib/types";
import { pb } from "@/lib/pocketbase";
+import { BaseForm } from "@/components/form/BaseForm";
+import { SingleLineInput } from "@/components/form/SingleLineInput";
/**
* Renders a form to add a new secret. Calls onCreate with the new secret document.
@@ -42,24 +44,18 @@ export const NewSecretForm = ({
}
return (
-
+
+ }
+ />
);
};
diff --git a/src/components/documents/treasure/NewTreasureForm.tsx b/src/components/documents/treasure/NewTreasureForm.tsx
index 2de22ab..28bf60b 100644
--- a/src/components/documents/treasure/NewTreasureForm.tsx
+++ b/src/components/documents/treasure/NewTreasureForm.tsx
@@ -3,6 +3,8 @@
import { useState } from "react";
import type { CampaignId, Treasure } from "@/lib/types";
import { pb } from "@/lib/pocketbase";
+import { BaseForm } from "@/components/form/BaseForm";
+import { SingleLineInput } from "@/components/form/SingleLineInput";
/**
* Renders a form to add a new treasure. Calls onCreate with the new treasure document.
@@ -42,29 +44,18 @@ export const NewTreasureForm = ({
}
return (
-
+ }
+ />
);
};
diff --git a/src/components/form/BaseForm.tsx b/src/components/form/BaseForm.tsx
index 6f4f3fa..0b4e3d3 100644
--- a/src/components/form/BaseForm.tsx
+++ b/src/components/form/BaseForm.tsx
@@ -17,12 +17,12 @@ export const BaseForm = ({
}: Props) => {
return (