@@ -52,9 +52,8 @@ export function useImportWorkflow({ workspaceId }: UseImportWorkflowProps) {
5252 const workflowName = extractWorkflowName ( content , filename )
5353 clearDiff ( )
5454
55- const parsedContent = JSON . parse ( content )
5655 const workflowColor =
57- parsedContent . state ?. metadata ?. color || parsedContent . metadata ?. color || '#3972F6'
56+ ( workflowData . metadata as { color ?: string } | undefined ) ?. color || '#3972F6'
5857
5958 const result = await createWorkflowMutation . mutateAsync ( {
6059 name : workflowName ,
@@ -66,12 +65,16 @@ export function useImportWorkflow({ workspaceId }: UseImportWorkflowProps) {
6665 } )
6766 const newWorkflowId = result . id
6867
69- await fetch ( `/api/workflows/${ newWorkflowId } /state` , {
68+ const stateResponse = await fetch ( `/api/workflows/${ newWorkflowId } /state` , {
7069 method : 'PUT' ,
7170 headers : { 'Content-Type' : 'application/json' } ,
7271 body : JSON . stringify ( workflowData ) ,
7372 } )
7473
74+ if ( ! stateResponse . ok ) {
75+ logger . error ( `Failed to save workflow state for ${ newWorkflowId } ` )
76+ }
77+
7578 if ( workflowData . variables ) {
7679 const variablesArray = Array . isArray ( workflowData . variables )
7780 ? workflowData . variables
@@ -94,11 +97,15 @@ export function useImportWorkflow({ workspaceId }: UseImportWorkflowProps) {
9497 }
9598 }
9699
97- await fetch ( `/api/workflows/${ newWorkflowId } /variables` , {
100+ const variablesResponse = await fetch ( `/api/workflows/${ newWorkflowId } /variables` , {
98101 method : 'POST' ,
99102 headers : { 'Content-Type' : 'application/json' } ,
100103 body : JSON . stringify ( { variables : variablesRecord } ) ,
101104 } )
105+
106+ if ( ! variablesResponse . ok ) {
107+ logger . error ( `Failed to save variables for ${ newWorkflowId } ` )
108+ }
102109 }
103110 }
104111
0 commit comments