Refactor Mixin

This commit is contained in:
Fayaz Ahmed 2022-05-13 16:44:35 +05:30
parent 1ebdd0e573
commit ab5d8ce311
2 changed files with 17 additions and 19 deletions

View file

@ -76,3 +76,14 @@ export const getOperatorTypes = key => {
return operatorMap[key] || OPERATOR_TYPES_1; return operatorMap[key] || OPERATOR_TYPES_1;
}; };
export const generateCustomAttributeTypes = customAttributes => {
return customAttributes.map(attr => {
return {
key: attr.attribute_key,
name: attr.attribute_display_name,
inputType: getCustomAttributeInputType(attr.attribute_display_type),
filterOperators: getOperatorTypes(attr.attribute_display_type),
};
});
};

View file

@ -10,6 +10,7 @@ import {
isCustomAttributeCheckbox, isCustomAttributeCheckbox,
isCustomAttributeList, isCustomAttributeList,
getOperatorTypes, getOperatorTypes,
generateCustomAttributeTypes,
} from '../../helper/automationHelper.js'; } from '../../helper/automationHelper.js';
const MESASAGE_CONDITION_VALUES = [ const MESASAGE_CONDITION_VALUES = [
@ -344,27 +345,13 @@ export default {
'attributes/getAttributesByModel' 'attributes/getAttributesByModel'
]('contact_attribute'); ]('contact_attribute');
const conversationCustomAttributeTypes = conversationCustomAttributesRaw.map( const conversationCustomAttributeTypes = generateCustomAttributeTypes(
attr => { conversationCustomAttributesRaw
return { );
key: attr.attribute_key, const contactCustomAttributeTypes = generateCustomAttributeTypes(
name: attr.attribute_display_name, contactCustomAttributesRaw
inputType: getCustomAttributeInputType(attr.attribute_display_type),
filterOperators: getOperatorTypes(attr.attribute_display_type),
};
}
); );
const contactCustomAttributeTypes = contactCustomAttributesRaw.map(
attr => {
return {
key: attr.attribute_key,
name: attr.attribute_display_name,
inputType: getCustomAttributeInputType(attr.attribute_display_type),
filterOperators: getOperatorTypes(attr.attribute_display_type),
};
}
);
const manifestedCustomAttributes = [ const manifestedCustomAttributes = [
{ {
key: 'conversation_custom_attribute', key: 'conversation_custom_attribute',