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:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user