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;
};
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,
isCustomAttributeList,
getOperatorTypes,
generateCustomAttributeTypes,
} from '../../helper/automationHelper.js';
const MESASAGE_CONDITION_VALUES = [
@ -344,27 +345,13 @@ export default {
'attributes/getAttributesByModel'
]('contact_attribute');
const conversationCustomAttributeTypes = conversationCustomAttributesRaw.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 conversationCustomAttributeTypes = generateCustomAttributeTypes(
conversationCustomAttributesRaw
);
const contactCustomAttributeTypes = generateCustomAttributeTypes(
contactCustomAttributesRaw
);
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 = [
{
key: 'conversation_custom_attribute',