11import React , { startTransition } from "react" ;
2- import { Flex , InputSyntaxSegment , useForm , useService , useStore } from "@code0-tech/pictor" ;
2+ import { Alert , InputSyntaxSegment , Spacing , Text , useForm , useService , useStore } from "@code0-tech/pictor" ;
33import {
44 Flow ,
55 LiteralValue ,
@@ -46,7 +46,12 @@ export const FunctionFileDefaultComponent: React.FC<FunctionFileDefaultComponent
4646 return values
4747 } , [ node , definition ] )
4848
49- const validations = React . useMemo ( ( ) => {
49+ const nodeValidation = React . useMemo (
50+ ( ) => validation ?. find ( v => v . nodeId === node . id && v . parameterIndex === null ) ,
51+ [ validation ]
52+ )
53+
54+ const parameterValidations = React . useMemo ( ( ) => {
5055 const values : Record < string , any > = { }
5156 definition ?. parameterDefinitions ?. nodes ?. forEach ( ( parameter , index ) => {
5257 values [ parameter ! . id ! ] = ( _ : any ) => {
@@ -114,17 +119,29 @@ export const FunctionFileDefaultComponent: React.FC<FunctionFileDefaultComponent
114119 useInitialValidation : true ,
115120 truthyValidationBeforeSubmit : false ,
116121 initialValues : initialValues ,
117- validate : validations ,
122+ validate : parameterValidations ,
118123 onSubmit : onSubmit
119124 } )
120125
121- console . log ( initialValues , node . id )
122-
123126 React . useEffect ( ( ) => {
124127 validate ( )
125128 } , [ validation ] )
126129
127- return < Flex style = { { gap : ".7rem" , flexDirection : "column" } } >
130+ return < >
131+ < Text size = { "md" } > { definition ?. names ?. [ 0 ] . content } </ Text >
132+ < Spacing spacing = { "xs" } />
133+ < Text hierarchy = { "tertiary" } > { definition ?. descriptions ?. [ 0 ] . content } </ Text >
134+ {
135+ nodeValidation && < >
136+ < Spacing spacing = { "xl" } />
137+ < Alert color = { "error" } >
138+ { nodeValidation ?. message ?. [ 0 ] ?. content as string }
139+ </ Alert >
140+ </ >
141+ }
142+ < Spacing spacing = { "xl" } />
143+ < Text size = { "md" } > Parameters</ Text >
144+ < Spacing spacing = { "xs" } />
128145 { definition ?. parameterDefinitions ?. nodes ?. map ( ( parameterDefinition , index ) => {
129146
130147 if ( ! parameterDefinition ) return null
@@ -147,7 +164,8 @@ export const FunctionFileDefaultComponent: React.FC<FunctionFileDefaultComponent
147164 } }
148165 { ...inputs . getInputProps ( parameterDefinition . id ! ) }
149166 />
167+ < Spacing spacing = { "xl" } />
150168 </ div >
151169 } ) }
152- </ Flex >
170+ </ >
153171}
0 commit comments