@@ -28,28 +28,33 @@ const ContactLowcoderModal: React.FC<ContactLowcoderModalProps> = ({
2828
2929 // Fetch deployment ID when modal opens
3030 useEffect ( ( ) => {
31- if ( visible && environment . environmentApiServiceUrl && environment . environmentApikey ) {
31+ const fetchDeploymentId = async ( ) => {
32+ if ( ! visible || ! environment . environmentApiServiceUrl || ! environment . environmentApikey ) {
33+ if ( visible ) {
34+ setError ( 'Environment API service URL or API key not configured' ) ;
35+ }
36+ return ;
37+ }
38+
3239 setIsLoading ( true ) ;
3340 setError ( null ) ;
3441
35- getEnvironmentDeploymentId (
36- environment . environmentApiServiceUrl ,
37- environment . environmentApikey
38- )
39- . then ( ( id ) => {
40- setDeploymentId ( id ) ;
41- setShowHubspotModal ( true ) ;
42- } )
43- . catch ( ( err ) => {
44- console . error ( 'Failed to fetch deployment ID:' , err ) ;
45- setError ( err instanceof Error ? err . message : 'Failed to fetch deployment ID' ) ;
46- } )
47- . finally ( ( ) => {
48- setIsLoading ( false ) ;
49- } ) ;
50- } else if ( visible ) {
51- setError ( 'Environment API service URL or API key not configured' ) ;
52- }
42+ try {
43+ const id = await getEnvironmentDeploymentId (
44+ environment . environmentApiServiceUrl ,
45+ environment . environmentApikey
46+ ) ;
47+ setDeploymentId ( id ) ;
48+ setShowHubspotModal ( true ) ;
49+ } catch ( err ) {
50+ console . error ( 'Failed to fetch deployment ID:' , err ) ;
51+ setError ( err instanceof Error ? err . message : 'Failed to fetch deployment ID' ) ;
52+ } finally {
53+ setIsLoading ( false ) ;
54+ }
55+ } ;
56+
57+ fetchDeploymentId ( ) ;
5358 } , [ visible , environment . environmentApiServiceUrl , environment . environmentApikey ] ) ;
5459
5560 // Handle HubSpot modal close
0 commit comments