Skip to content

Commit 335b2d1

Browse files
authored
Merge pull request #2635 from JohnDuprey/dev
Extension Mapping
2 parents ac76cb8 + 018b0d0 commit 335b2d1

File tree

1 file changed

+9
-45
lines changed

1 file changed

+9
-45
lines changed

src/views/cipp/ExtensionMappings.jsx

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,6 @@ export default function ExtensionMappings({ type, fieldMappings = false, autoMap
4040
setMappingValue({})
4141
})
4242
}
43-
/*const onNinjaOrgsSubmit = () => {
44-
const originalFormat = ninjaMappingsArray.reduce((acc, item) => {
45-
acc[item.Tenant?.customerId] = { label: item.ninjaName, value: item.ninjaId }
46-
return acc
47-
}, {})
48-
49-
setNinjaOrgsExtensionconfig({
50-
path: 'api/ExecExtensionMapping?AddMapping=NinjaOrgs',
51-
values: { mappings: originalFormat },
52-
}).then(() => {
53-
listNinjaOrgsBackend({ path: 'api/ExecExtensionMapping?List=NinjaOrgs' })
54-
setMappingValue({})
55-
})
56-
}*/
5743

5844
const onOrgsAutomap = async (values) => {
5945
if (autoMapSyncApi) {
@@ -66,16 +52,17 @@ export default function ExtensionMappings({ type, fieldMappings = false, autoMap
6652
})
6753
}
6854

69-
const newMappings = listMappingBackendResult.data?.Tenants.map((tenant) => {
55+
var newMappings = []
56+
listMappingBackendResult.data?.Tenants.map((tenant) => {
7057
const company = listMappingBackendResult.data?.Companies.find(
7158
(client) => client.name === tenant.displayName,
7259
)
73-
if (company) {
74-
return {
60+
if (company !== undefined && !mappingArray.find((item) => item.companyId === company.value)) {
61+
newMappings.push({
7562
Tenant: tenant,
7663
companyName: company.name,
7764
companyId: company.value,
78-
}
65+
})
7966
}
8067
})
8168
setMappingArray((currentMappings) => [...currentMappings, ...newMappings])
@@ -89,32 +76,6 @@ export default function ExtensionMappings({ type, fieldMappings = false, autoMap
8976
})
9077
}
9178

92-
/*const onHaloAutomap = () => {
93-
const newMappings = listBackendHaloResult.data?.Tenants.map(
94-
(tenant) => {
95-
const haloClient = listBackendHaloResult.data?.HaloClients.find(
96-
(client) => client.name === tenant.displayName,
97-
)
98-
if (haloClient) {
99-
console.log(haloClient)
100-
console.log(tenant)
101-
return {
102-
Tenant: tenant,
103-
haloName: haloClient.name,
104-
haloId: haloClient.value,
105-
}
106-
}
107-
},
108-
//filter out any undefined values
109-
).filter((item) => item !== undefined)
110-
setHaloMappingsArray((currentHaloMappings) => [...currentHaloMappings, ...newMappings]).then(
111-
() => {
112-
listHaloBackend({ path: 'api/ExecExtensionMapping?List=Halo' })
113-
},
114-
)
115-
setHaloAutoMap(true)
116-
}*/
117-
11879
useEffect(() => {
11980
if (listMappingBackendResult.isSuccess) {
12081
setMappingArray(
@@ -127,7 +88,7 @@ export default function ExtensionMappings({ type, fieldMappings = false, autoMap
12788
})),
12889
)
12990
}
130-
}, [listMappingBackendResult])
91+
}, [listMappingBackendResult, setMappingArray])
13192

13293
const Actions = (row, rowIndex, formatExtraData) => {
13394
return (
@@ -232,6 +193,9 @@ export default function ExtensionMappings({ type, fieldMappings = false, autoMap
232193
columns={columns}
233194
data={mappingArray}
234195
isModal={true}
196+
refreshFunction={() =>
197+
listMappingBackend({ path: `api/ExecExtensionMapping?List=${type}` })
198+
}
235199
/>
236200
)
237201
}

0 commit comments

Comments
 (0)