From d185ae1feba6e492b38d62da84eb201ee2508c7d Mon Sep 17 00:00:00 2001 From: John Duprey Date: Mon, 3 Feb 2025 21:23:57 -0500 Subject: [PATCH] fix tenant mapping and buttons --- .../CippIntegrationTenantMapping.jsx | 60 +++++++++---------- src/pages/cipp/integrations/configure.js | 5 +- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/components/CippIntegrations/CippIntegrationTenantMapping.jsx b/src/components/CippIntegrations/CippIntegrationTenantMapping.jsx index 8f1ecc67ec5c..6bc3e95caea6 100644 --- a/src/components/CippIntegrations/CippIntegrationTenantMapping.jsx +++ b/src/components/CippIntegrations/CippIntegrationTenantMapping.jsx @@ -95,37 +95,37 @@ const CippIntegrationSettings = ({ children }) => { }; const handleAutoMap = () => { - const newTableData = []; - tenantList.data?.pages[0]?.forEach((tenant) => { - const matchingCompany = mappings.data.Companies.find( - (company) => company.name === tenant.displayName - ); - if ( - Array.isArray(tableData) && - tableData?.find((item) => item.TenantId === tenant.customerId) - ) - return; - if (matchingCompany) { - newTableData.push({ - TenantId: tenant.customerId, - Tenant: tenant.displayName, - IntegrationName: matchingCompany.name, - IntegrationId: matchingCompany.value, - }); - } - }); - if (Array.isArray(tableData)) { - setTableData([...tableData, ...newTableData]); - } else { - setTableData(newTableData); - } - if (extension.autoMapSyncApi) { - automapPostCall.mutate({ - url: `/api/ExecExtensionMapping?AutoMapping=${router.query.id}`, - queryKey: `IntegrationTenantMapping-${router.query.id}`, + const newTableData = []; + tenantList.data?.pages[0]?.forEach((tenant) => { + const matchingCompany = mappings.data.Companies.find( + (company) => company.name === tenant.displayName + ); + if ( + Array.isArray(tableData) && + tableData?.find((item) => item.TenantId === tenant.customerId) + ) + return; + if (matchingCompany) { + newTableData.push({ + TenantId: tenant.customerId, + Tenant: tenant.displayName, + IntegrationName: matchingCompany.name, + IntegrationId: matchingCompany.value, }); } - }; + }); + if (Array.isArray(tableData)) { + setTableData([...tableData, ...newTableData]); + } else { + setTableData(newTableData); + } + if (extension.autoMapSyncApi) { + automapPostCall.mutate({ + url: `/api/ExecExtensionMapping?AutoMapping=${router.query.id}`, + queryKey: `IntegrationTenantMapping-${router.query.id}`, + }); + } + }; const actions = [ { @@ -140,7 +140,7 @@ const CippIntegrationSettings = ({ children }) => { useEffect(() => { if (mappings.isSuccess) { - setTableData(mappings.data.Mappings); + setTableData(mappings.data.Mappings ?? []); } }, [mappings.isSuccess]); diff --git a/src/pages/cipp/integrations/configure.js b/src/pages/cipp/integrations/configure.js index 62bc4990350b..e45bf0fd4489 100644 --- a/src/pages/cipp/integrations/configure.js +++ b/src/pages/cipp/integrations/configure.js @@ -174,10 +174,9 @@ const Page = () => { ))} )} - - - + +