@@ -101,58 +101,123 @@ const Page = () => {
101101 const allStandards = [ ] ;
102102 if ( selectedTemplate . standards ) {
103103 Object . entries ( selectedTemplate . standards ) . forEach ( ( [ standardKey , standardConfig ] ) => {
104- const standardId = `standards.${ standardKey } ` ;
105- const standardInfo = standards . find ( ( s ) => s . name === standardId ) ;
106- const standardSettings = standardConfig . standards ?. [ standardKey ] || { } ;
107-
108- // Find the tenant's value for this standard
109- const currentTenantStandard = currentTenantData . find (
110- ( s ) => s . standardId === standardId
111- ) ;
112-
113- // Determine compliance status
114- let isCompliant = false ;
115-
116- // Check if the standard is directly in the tenant object (like "standards.AuditLog": true)
117- const standardIdWithoutPrefix = standardId . replace ( "standards." , "" ) ;
118- const directStandardValue = currentTenantObj ?. [ standardId ] ;
119-
120- // Special case for boolean standards that are true in the tenant
121- if ( directStandardValue === true ) {
122- // If the standard is directly in the tenant and is true, it's compliant
123- isCompliant = true ;
124- } else if ( directStandardValue !== undefined ) {
125- // For non-boolean values, use strict equality
126- isCompliant =
127- JSON . stringify ( directStandardValue ) === JSON . stringify ( standardSettings ) ;
128- } else if ( currentTenantStandard ) {
129- // Fall back to the previous logic if the standard is not directly in the tenant object
130- if ( typeof standardSettings === "boolean" && standardSettings === true ) {
131- isCompliant = currentTenantStandard . value === true ;
132- } else {
104+ // Special handling for IntuneTemplate which is an array of items
105+ if ( standardKey === "IntuneTemplate" && Array . isArray ( standardConfig ) ) {
106+ // Process each IntuneTemplate item separately
107+ standardConfig . forEach ( ( templateItem , index ) => {
108+ const templateId = templateItem . TemplateList ?. value ;
109+ if ( templateId ) {
110+ const standardId = `standards.IntuneTemplate.${ templateId } ` ;
111+ const standardInfo = standards . find ( ( s ) => s . name === `standards.IntuneTemplate` ) ;
112+
113+ // Find the tenant's value for this specific template
114+ const currentTenantStandard = currentTenantData . find (
115+ ( s ) => s . standardId === standardId
116+ ) ;
117+
118+ // Get the direct standard value from the tenant object
119+ const directStandardValue = currentTenantObj ?. [ standardId ] ;
120+
121+ // Determine compliance status
122+ let isCompliant = false ;
123+
124+ // For IntuneTemplate, the value is true if compliant, or an object with comparison data if not compliant
125+ if ( directStandardValue === true ) {
126+ isCompliant = true ;
127+ } else if (
128+ directStandardValue !== undefined &&
129+ typeof directStandardValue !== "object"
130+ ) {
131+ isCompliant = true ;
132+ } else if ( currentTenantStandard ) {
133+ isCompliant = currentTenantStandard . value === true ;
134+ }
135+
136+ // Create a standardValue object that contains the template settings
137+ const templateSettings = {
138+ templateId,
139+ Template : templateItem . TemplateList ?. label || "Unknown Template" ,
140+ "Assign to" : templateItem . AssignTo || "On" ,
141+ "Excluded Group" : templateItem . excludeGroup || "" ,
142+ "Included Group" : templateItem . customGroup || "" ,
143+ } ;
144+
145+ allStandards . push ( {
146+ standardId,
147+ standardName : `IntuneTemplate: ${
148+ templateItem . TemplateList ?. label || templateId
149+ } `,
150+ currentTenantValue :
151+ directStandardValue !== undefined
152+ ? directStandardValue
153+ : currentTenantStandard ?. value ,
154+ standardValue : templateSettings , // Use the template settings object instead of true
155+ complianceStatus : isCompliant ? "Compliant" : "Non-Compliant" ,
156+ complianceDetails :
157+ standardInfo ?. docsDescription || standardInfo ?. helpText || "" ,
158+ standardDescription : standardInfo ?. helpText || "" ,
159+ standardImpact : standardInfo ?. impact || "Medium Impact" ,
160+ standardImpactColour : standardInfo ?. impactColour || "warning" ,
161+ templateName : selectedTemplate ?. templateName || "Standard Template" ,
162+ templateActions : templateItem . action || [ ] ,
163+ } ) ;
164+ }
165+ } ) ;
166+ } else {
167+ // Regular handling for other standards
168+ const standardId = `standards.${ standardKey } ` ;
169+ const standardInfo = standards . find ( ( s ) => s . name === standardId ) ;
170+ const standardSettings = standardConfig . standards ?. [ standardKey ] || { } ;
171+
172+ // Find the tenant's value for this standard
173+ const currentTenantStandard = currentTenantData . find (
174+ ( s ) => s . standardId === standardId
175+ ) ;
176+
177+ // Determine compliance status
178+ let isCompliant = false ;
179+
180+ // Check if the standard is directly in the tenant object (like "standards.AuditLog": true)
181+ const standardIdWithoutPrefix = standardId . replace ( "standards." , "" ) ;
182+ const directStandardValue = currentTenantObj ?. [ standardId ] ;
183+
184+ // Special case for boolean standards that are true in the tenant
185+ if ( directStandardValue === true ) {
186+ // If the standard is directly in the tenant and is true, it's compliant
187+ isCompliant = true ;
188+ } else if ( directStandardValue !== undefined ) {
189+ // For non-boolean values, use strict equality
133190 isCompliant =
134- JSON . stringify ( currentTenantStandard . value ) === JSON . stringify ( standardSettings ) ;
191+ JSON . stringify ( directStandardValue ) === JSON . stringify ( standardSettings ) ;
192+ } else if ( currentTenantStandard ) {
193+ // Fall back to the previous logic if the standard is not directly in the tenant object
194+ if ( typeof standardSettings === "boolean" && standardSettings === true ) {
195+ isCompliant = currentTenantStandard . value === true ;
196+ } else {
197+ isCompliant =
198+ JSON . stringify ( currentTenantStandard . value ) ===
199+ JSON . stringify ( standardSettings ) ;
200+ }
135201 }
136- }
137202
138- // Use the direct standard value from the tenant object if it exists
139-
140- allStandards . push ( {
141- standardId,
142- standardName : standardId || standardKey ,
143- currentTenantValue :
144- directStandardValue !== undefined
145- ? directStandardValue
146- : currentTenantStandard ?. value ,
147- standardValue : standardSettings ,
148- complianceStatus : isCompliant ? "Compliant" : "Non-Compliant ",
149- complianceDetails : standardInfo ?. docsDescription || standardInfo ?. helpText || "" ,
150- standardDescription : standardInfo ?. helpText || "" ,
151- standardImpact : standardInfo ?. impact || "Medium Impact " ,
152- standardImpactColour : standardInfo ?. impactColour || "warning " ,
153- templateName : selectedTemplate . templateName || "Standard Template" ,
154- templateActions : standardConfig . action || [ ] ,
155- } ) ;
203+ // Use the direct standard value from the tenant object if it exists
204+ allStandards . push ( {
205+ standardId ,
206+ standardName : standardId || standardKey ,
207+ currentTenantValue :
208+ directStandardValue !== undefined
209+ ? directStandardValue
210+ : currentTenantStandard ?. value ,
211+ standardValue : standardSettings ,
212+ complianceStatus : isCompliant ? "Compliant" : "Non-Compliant" ,
213+ complianceDetails : standardInfo ?. docsDescription || standardInfo ?. helpText || " ",
214+ standardDescription : standardInfo ?. helpText || "" ,
215+ standardImpact : standardInfo ?. impact || "Medium Impact " ,
216+ standardImpactColour : standardInfo ?. impactColour || "warning " ,
217+ templateName : selectedTemplate . templateName || "Standard Template " ,
218+ templateActions : standardConfig . action || [ ] ,
219+ } ) ;
220+ }
156221 } ) ;
157222 }
158223
@@ -193,8 +258,8 @@ const Page = () => {
193258 < Stack direction = "row" alignItems = "space-between" spacing = { 2 } >
194259 < Typography variant = "h4" width = { "100%" } >
195260 {
196- templateDetails ?. data ?. filter ( ( template ) => template . GUID === templateId ) [ 0 ]
197- . templateName
261+ templateDetails ?. data ?. filter ( ( template ) => template . GUID === templateId ) ?. [ 0 ]
262+ ? .templateName
198263 }
199264 </ Typography >
200265 < Tooltip title = "Refresh Data" >
@@ -220,8 +285,8 @@ const Page = () => {
220285 </ Stack >
221286 ) }
222287 </ Stack >
223- { templateDetails ?. data ?. filter ( ( template ) => template . GUID === templateId ) [ 0 ]
224- . description && (
288+ { templateDetails ?. data ?. filter ( ( template ) => template . GUID === templateId ) ?. [ 0 ]
289+ ? .description && (
225290 < Box
226291 sx = { {
227292 "& a" : {
0 commit comments