Moves editing into forms. Every doc has a page now. BUG: state not refreshed after mutation
This commit is contained in:
25
src/components/documents/scene/SceneEditForm.tsx
Normal file
25
src/components/documents/scene/SceneEditForm.tsx
Normal 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>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user