fix: save button now fully persists canvas to DB

Root cause: handleAddNode/handleEdgeConfirm only updated Zustand store,
never creating records in the DB. canvasApi.save() only updated positions
of existing nodes, so nothing survived a page refresh.

Fix: save now sends the full canvas state (all nodes + edges + data) and
the backend does a full sync — upsert incoming, delete anything removed.
This means Save is the single source of truth: no need to call individual
create/update/delete APIs for every drag or edit.
This commit is contained in:
Pouzor
2026-03-07 01:54:59 +01:00
parent 3f8d23d215
commit 9eba62c5b5
4 changed files with 96 additions and 16 deletions
+5 -2
View File
@@ -26,8 +26,11 @@ export const authApi = {
export const canvasApi = {
load: () => api.get('/canvas'),
save: (payload: { node_positions: { id: string; x: number; y: number }[]; viewport: object }) =>
api.post('/canvas/save', payload),
save: (payload: {
nodes: object[]
edges: object[]
viewport: object
}) => api.post('/canvas/save', payload),
}
export const nodesApi = {