Moves editing into forms. Every doc has a page now. BUG: state not refreshed after mutation

This commit is contained in:
2025-06-13 16:58:26 -07:00
parent 293e1f9f62
commit ad8fb07c69
14 changed files with 313 additions and 59 deletions

View File

@@ -0,0 +1,30 @@
import { AutoSaveTextarea } from "@/components/AutoSaveTextarea";
import { pb } from "@/lib/pocketbase";
import type { Monster } from "@/lib/types";
/**
* Renders an editable monster row
*/
export const MonsterEditForm = ({ monster }: { monster: Monster }) => {
async function saveMonsterName(name: string) {
await pb.collection("documents").update(monster.id, {
data: {
...monster.data,
monster: {
...monster.data.monster,
name,
},
},
});
}
return (
<div className="">
<AutoSaveTextarea
multiline={false}
value={monster.data.monster.name}
onSave={saveMonsterName}
/>
</div>
);
};