Forms now update documents directly.
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
import { AutoSaveTextarea } from "@/components/AutoSaveTextarea";
|
||||
import { pb } from "@/lib/pocketbase";
|
||||
import type { Scene } from "@/lib/types";
|
||||
import { useDocument } from "@/context/document/DocumentContext";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
/**
|
||||
* Renders an editable scene form
|
||||
*/
|
||||
export const SceneEditForm = ({ scene }: { scene: Scene }) => {
|
||||
const { dispatch } = useDocument();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
async function saveScene(text: string) {
|
||||
await pb.collection("documents").update(scene.id, {
|
||||
const updated: Scene = await pb.collection("documents").update(scene.id, {
|
||||
data: {
|
||||
...scene.data,
|
||||
text,
|
||||
},
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["relationship"],
|
||||
});
|
||||
dispatch({ type: "setDocument", doc: updated });
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user