@@ -12,6 +12,8 @@ export interface IPostgresFormProps {
1212}
1313
1414export const PostgresForm : React . FC < IPostgresFormProps > = ( { integrationId, existingConfig, onSave, onCancel } ) => {
15+ console . log ( '[PostgresForm] Rendering with existingConfig:' , existingConfig ) ;
16+
1517 const [ name , setName ] = React . useState ( existingConfig ?. name || '' ) ;
1618 const [ host , setHost ] = React . useState ( existingConfig ?. host || '' ) ;
1719 const [ port , setPort ] = React . useState ( existingConfig ?. port ?. toString ( ) || '5432' ) ;
@@ -20,6 +22,19 @@ export const PostgresForm: React.FC<IPostgresFormProps> = ({ integrationId, exis
2022 const [ password , setPassword ] = React . useState ( existingConfig ?. password || '' ) ;
2123 const [ ssl , setSsl ] = React . useState ( existingConfig ?. ssl || false ) ;
2224
25+ // Update form fields when existingConfig changes
26+ React . useEffect ( ( ) => {
27+ if ( existingConfig ) {
28+ setName ( existingConfig . name || '' ) ;
29+ setHost ( existingConfig . host || '' ) ;
30+ setPort ( existingConfig . port ?. toString ( ) || '5432' ) ;
31+ setDatabase ( existingConfig . database || '' ) ;
32+ setUsername ( existingConfig . username || '' ) ;
33+ setPassword ( existingConfig . password || '' ) ;
34+ setSsl ( existingConfig . ssl || false ) ;
35+ }
36+ } , [ existingConfig ] ) ;
37+
2338 const handleSubmit = ( e : React . FormEvent ) => {
2439 e . preventDefault ( ) ;
2540
@@ -139,4 +154,3 @@ export const PostgresForm: React.FC<IPostgresFormProps> = ({ integrationId, exis
139154 </ form >
140155 ) ;
141156} ;
142-
0 commit comments