2021-09-30 23:02:18 +05:30
|
|
|
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
export const augmentFeatures = (securityFeatures, complianceFeatures, features = []) => {
|
|
|
|
const featuresByType = features.reduce((acc, feature) => {
|
2021-09-30 23:02:18 +05:30
|
|
|
acc[feature.type] = convertObjectPropsToCamelCase(feature, { deep: true });
|
2021-09-04 01:27:46 +05:30
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
const augmentFeature = (feature) => {
|
|
|
|
const augmented = {
|
|
|
|
...feature,
|
|
|
|
...featuresByType[feature.type],
|
|
|
|
};
|
|
|
|
|
|
|
|
if (augmented.secondary) {
|
|
|
|
augmented.secondary = { ...augmented.secondary, ...featuresByType[feature.secondary.type] };
|
|
|
|
}
|
|
|
|
|
|
|
|
return augmented;
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
augmentedSecurityFeatures: securityFeatures.map((feature) => augmentFeature(feature)),
|
|
|
|
augmentedComplianceFeatures: complianceFeatures.map((feature) => augmentFeature(feature)),
|
|
|
|
};
|
|
|
|
};
|