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,25 @@
import { AutoSaveTextarea } from "@/components/AutoSaveTextarea";
import { pb } from "@/lib/pocketbase";
import type { Scene } from "@/lib/types";
/**
* Renders an editable scene form
*/
export const SceneEditForm = ({ scene }: { scene: Scene }) => {
async function saveScene(text: string) {
await pb.collection("documents").update(scene.id, {
data: {
...scene.data,
scene: {
text,
},
},
});
}
return (
<div className="">
<AutoSaveTextarea value={scene.data.scene.text} onSave={saveScene} />
</div>
);
};