Forms now update documents directly.
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
import { AutoSaveTextarea } from "@/components/AutoSaveTextarea";
|
||||
import { pb } from "@/lib/pocketbase";
|
||||
import type { Monster } from "@/lib/types";
|
||||
import { useDocument } from "@/context/document/DocumentContext";
|
||||
|
||||
/**
|
||||
* Renders an editable monster row
|
||||
*/
|
||||
export const MonsterEditForm = ({ monster }: { monster: Monster }) => {
|
||||
const { dispatch } = useDocument();
|
||||
async function saveMonsterName(name: string) {
|
||||
await pb.collection("documents").update(monster.id, {
|
||||
const updated = await pb.collection("documents").update(monster.id, {
|
||||
data: {
|
||||
...monster.data,
|
||||
name,
|
||||
},
|
||||
});
|
||||
dispatch({ type: "setDocument", doc: updated });
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user