@@ -95,37 +95,37 @@ const CippIntegrationSettings = ({ children }) => {
9595 } ;
9696
9797 const handleAutoMap = ( ) => {
98- const newTableData = [ ] ;
99- tenantList . data ?. pages [ 0 ] ?. forEach ( ( tenant ) => {
100- const matchingCompany = mappings . data . Companies . find (
101- ( company ) => company . name === tenant . displayName
102- ) ;
103- if (
104- Array . isArray ( tableData ) &&
105- tableData ?. find ( ( item ) => item . TenantId === tenant . customerId )
106- )
107- return ;
108- if ( matchingCompany ) {
109- newTableData . push ( {
110- TenantId : tenant . customerId ,
111- Tenant : tenant . displayName ,
112- IntegrationName : matchingCompany . name ,
113- IntegrationId : matchingCompany . value ,
114- } ) ;
115- }
116- } ) ;
117- if ( Array . isArray ( tableData ) ) {
118- setTableData ( [ ...tableData , ...newTableData ] ) ;
119- } else {
120- setTableData ( newTableData ) ;
121- }
122- if ( extension . autoMapSyncApi ) {
123- automapPostCall . mutate ( {
124- url : `/api/ExecExtensionMapping?AutoMapping=${ router . query . id } ` ,
125- queryKey : `IntegrationTenantMapping-${ router . query . id } ` ,
98+ const newTableData = [ ] ;
99+ tenantList . data ?. pages [ 0 ] ?. forEach ( ( tenant ) => {
100+ const matchingCompany = mappings . data . Companies . find (
101+ ( company ) => company . name === tenant . displayName
102+ ) ;
103+ if (
104+ Array . isArray ( tableData ) &&
105+ tableData ?. find ( ( item ) => item . TenantId === tenant . customerId )
106+ )
107+ return ;
108+ if ( matchingCompany ) {
109+ newTableData . push ( {
110+ TenantId : tenant . customerId ,
111+ Tenant : tenant . displayName ,
112+ IntegrationName : matchingCompany . name ,
113+ IntegrationId : matchingCompany . value ,
126114 } ) ;
127115 }
128- } ;
116+ } ) ;
117+ if ( Array . isArray ( tableData ) ) {
118+ setTableData ( [ ...tableData , ...newTableData ] ) ;
119+ } else {
120+ setTableData ( newTableData ) ;
121+ }
122+ if ( extension . autoMapSyncApi ) {
123+ automapPostCall . mutate ( {
124+ url : `/api/ExecExtensionMapping?AutoMapping=${ router . query . id } ` ,
125+ queryKey : `IntegrationTenantMapping-${ router . query . id } ` ,
126+ } ) ;
127+ }
128+ } ;
129129
130130 const actions = [
131131 {
@@ -140,7 +140,7 @@ const CippIntegrationSettings = ({ children }) => {
140140
141141 useEffect ( ( ) => {
142142 if ( mappings . isSuccess ) {
143- setTableData ( mappings . data . Mappings ) ;
143+ setTableData ( mappings . data . Mappings ?? [ ] ) ;
144144 }
145145 } , [ mappings . isSuccess ] ) ;
146146
0 commit comments