This commit is contained in:
2026-05-04 04:02:50 +05:00
parent 0c19af34c3
commit 4ddcaec7c8
6 changed files with 119 additions and 10 deletions
+7 -3
View File
@@ -41,6 +41,7 @@ export const useCanvas = () => {
}
const parseCanvasJson = (json: any): CanvasData => {
if (!json) return { nodes: [], edges: [] }
const nodes = (json.nodes || []).map((n: any) => ({
id: n.id,
type: n.type,
@@ -88,11 +89,14 @@ export const useCanvas = () => {
return token ? { Authorization: `Bearer ${token}` } : {}
}
const loadCanvas = async (id: string): Promise<CanvasData> => {
const data = await $fetch(`/api/canvas/${id}`, {
const loadCanvas = async (id: string): Promise<{ canvas: CanvasData, role: string }> => {
const data = await $fetch<{ canvas: any, role: string }>(`/api/canvas/${id}`, {
headers: getAuthHeaders()
})
return parseCanvasJson(data)
return {
canvas: parseCanvasJson(data.canvas),
role: data.role
}
}
const updateNodeState = async (nodeId: string, state: string) => {