@@ -109,7 +109,7 @@ const ConversationConfiguration = ({ appInfo, updateUserContext, chatRunning, is
109109 />
110110 ) ;
111111 case 'switch' :
112- return < Switch onChange = { updateData } checked = { ! ! value } /> ;
112+ return < Switch onChange = { updateData } /> ;
113113 case 'dropdown' :
114114 return (
115115 < Select
@@ -195,7 +195,9 @@ const ConversationConfiguration = ({ appInfo, updateUserContext, chatRunning, is
195195 const preItem = preConfigurationList . current . find ( it => it . name === item . name ) ;
196196 const isChangeType = preItem ?. type !== item . type ;
197197 if ( item . type === 'Boolean' ) {
198- form . setFieldValue ( item . name , isChangeType ? false : ( form . getFieldValue ( item . name ) || false ) ) ;
198+ const existingValue = form . getFieldValue ( item . name ) ;
199+ const defaultValue = item . value ?? false ;
200+ form . setFieldValue ( item . name , isChangeType ? defaultValue : ( existingValue ?? defaultValue ) ) ;
199201 } else {
200202 form . setFieldValue ( item . name , isChangeType ? null : ( ( isInputEmpty ( form . getFieldValue ( item . name ) ) ? null : form . getFieldValue ( item . name ) ) ) ) ;
201203 }
@@ -264,24 +266,33 @@ const ConversationConfiguration = ({ appInfo, updateUserContext, chatRunning, is
264266 < >
265267 < div className = 'configuration-header' >
266268 < span className = 'configuration-title' > { t ( 'conversationConfiguration' ) } </ span >
267- < img src = { CloseImg } alt = "" onClick = { ( ) => setOpen ( false ) } />
269+ < img src = { CloseImg } alt = '' onClick = { ( ) => setOpen ( false ) } />
268270 </ div >
269271 < div className = 'configuration-content' >
270- {
271- configurationList ?. length > 0 ? < Form form = { form } autoComplete = 'off' >
272- {
273- configurationList . map ( config =>
274- < Form . Item
275- key = { config . id }
276- name = { config . name }
277- label = { config . displayName || ' ' }
278- className = { config . isRequired ? 'is-required' : '' } >
279- { getConfigurationItem ( { ...config , value : form . getFieldValue ( config . value ) } ) }
280- </ Form . Item >
281- )
282- }
283- </ Form > : < Empty description = { t ( 'noData' ) } > </ Empty >
284- }
272+ { configurationList ?. length > 0 ? (
273+ < Form
274+ form = { form }
275+ autoComplete = 'off'
276+ >
277+ { configurationList . map ( ( config ) => (
278+ < Form . Item
279+ key = { config . id }
280+ name = { config . name }
281+ label = { config . displayName || ' ' }
282+ className = { config . isRequired ? 'is-required' : '' }
283+ valuePropName = {
284+ config . type === 'Boolean' || config . appearance ?. displayType === 'switch'
285+ ? 'checked'
286+ : 'value'
287+ }
288+ >
289+ { getConfigurationItem ( { ...config , value : form . getFieldValue ( config . name ) } ) }
290+ </ Form . Item >
291+ ) ) }
292+ </ Form >
293+ ) : (
294+ < Empty description = { t ( 'noData' ) } > </ Empty >
295+ ) }
285296 </ div >
286297 </ >
287298 ) ;
0 commit comments