Skip to content

Commit 0dcd7df

Browse files
committed
[Enhancement] Refine email handling in Create Contact action
1 parent 5f7706e commit 0dcd7df

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

components/aircall/actions/create-contact/create-contact.mjs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ export default {
1414
type: "string[]",
1515
label: "Emails",
1616
description:
17-
"Array of email address objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value.",
17+
"Array of email address objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value. For example, `{{ [{\"label\": \"Work\", \"value\": \"[email protected]\"}] }}`, or `{{ [\"[email protected]\"] }}`",
1818
optional: true,
1919
},
2020
phoneNumbers: {
2121
type: "string[]",
2222
label: "Phone Numbers",
2323
description:
24-
"Array of phone number objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value. For example, `{{ [{\"label\": \"test1\", \"value\": \"+1 812-641-5139\"}] }}`, or `{{ [\"+1 812-641-5139\"] }}`",
24+
"Array of phone number objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value. For example, `{{ [{\"label\": \"Work\", \"value\": \"+1 812-641-5139\"}] }}`, or `{{ [\"+1 812-641-5139\"] }}`",
2525
},
2626
},
2727
async run({ $ }) {
@@ -35,10 +35,20 @@ export default {
3535
value: item,
3636
};
3737
});
38+
const refinedEmails = this.emails.map((item) => {
39+
if (typeof item === "object" && item !== null) {
40+
return item;
41+
}
42+
43+
return {
44+
label: item,
45+
value: item,
46+
};
47+
});
3848

3949
const data = {
4050
...this.getCommonData(),
41-
emails: this.emails,
51+
emails: refinedEmails,
4252
phone_numbers: refinedPhoneNumbers,
4353
};
4454

0 commit comments

Comments
 (0)