Forms now update documents directly.
This commit is contained in:
@@ -5,6 +5,7 @@ import type { CampaignId, Scene } from "@/lib/types";
|
||||
import { pb } from "@/lib/pocketbase";
|
||||
import { BaseForm } from "@/components/form/BaseForm";
|
||||
import { MultiLineInput } from "@/components/form/MultiLineInput";
|
||||
import { useDocument } from "@/context/document/DocumentContext";
|
||||
|
||||
/**
|
||||
* Renders a form to add a new scene. Calls onCreate with the new scene document.
|
||||
@@ -16,6 +17,7 @@ export const NewSceneForm = ({
|
||||
campaign: CampaignId;
|
||||
onCreate: (scene: Scene) => Promise<void>;
|
||||
}) => {
|
||||
const { dispatch } = useDocument();
|
||||
const [text, setText] = useState("");
|
||||
const [adding, setAdding] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -34,6 +36,7 @@ export const NewSceneForm = ({
|
||||
},
|
||||
});
|
||||
setText("");
|
||||
dispatch({ type: "setDocument", doc: sceneDoc });
|
||||
await onCreate(sceneDoc);
|
||||
} catch (e: any) {
|
||||
setError(e?.message || "Failed to add scene.");
|
||||
|
||||
Reference in New Issue
Block a user