diff --git a/models/interfaces.ts b/models/interfaces.ts index 083b1799..780c7133 100644 --- a/models/interfaces.ts +++ b/models/interfaces.ts @@ -44,7 +44,7 @@ export interface ChannelItemType extends ConfigType { }; email?: { email_account_id: string; - recipient_list: string[]; // custom email addresses + recipient_list: { [recipient: string]: string }[]; // custom email addresses email_group_id_list: string[]; // optional fields for displaying or editing email channel, needs more requests sender_type?: SenderType; diff --git a/public/pages/CreateChannel/__tests__/helper.test.ts b/public/pages/CreateChannel/__tests__/helper.test.ts index 0f1a88a5..9954da27 100644 --- a/public/pages/CreateChannel/__tests__/helper.test.ts +++ b/public/pages/CreateChannel/__tests__/helper.test.ts @@ -154,7 +154,10 @@ describe('constructs and deconstructs email objects', () => { 'recipient-group-id-2', 'recipient-group-id-3', ], - recipient_list: ['custom.address1@email.com', 'custom.address2@email.com'], + recipient_list: [ + { recipient: 'custom.address1@email.com' }, + { recipient: 'custom.address2@email.com' }, + ], }; it('constructs email objects', () => { diff --git a/public/pages/CreateChannel/utils/helper.ts b/public/pages/CreateChannel/utils/helper.ts index cfa26c80..ee7ddf20 100644 --- a/public/pages/CreateChannel/utils/helper.ts +++ b/public/pages/CreateChannel/utils/helper.ts @@ -112,7 +112,7 @@ export const constructEmailObject = ( if (group.value) { recipientGroupIds.push(group.value); } else { - customEmailsList.push(group.label); + customEmailsList.push({ recipient: group.label }); } } return { @@ -142,7 +142,7 @@ export const deconstructEmailObject = ( label: _.get(email.email_group_id_map, groupId, '-'), value: groupId, })), - ...email.recipient_list.map((address) => ({ label: address })), + ...email.recipient_list.map((recipient) => ({ label: recipient.recipient })), ]; return { senderType: email.sender_type!, diff --git a/test/mocks/mockData.ts b/test/mocks/mockData.ts index 6106ff96..ec57596e 100644 --- a/test/mocks/mockData.ts +++ b/test/mocks/mockData.ts @@ -43,7 +43,11 @@ const mockEmail: ChannelItemType = { is_enabled: true, email: { email_account_id: 'dj8etXkBCzVy9Vy-nsiL', - recipient_list: ['custom@email.com', 'email@test.com', 'test@email.com'], + recipient_list: [ + { recipient: 'custom@email.com' }, + { recipient: 'email@test.com' }, + { recipient: 'test@email.com' }, + ], email_group_id_list: [ '1l8hq3kB0XwiBlEbanSo', 'dz8etXkBCzVy9Vy-0sgh', @@ -76,7 +80,11 @@ const mockEmailWithSES: ChannelItemType = { is_enabled: true, email: { email_account_id: 'dj8etXkBCzVy9Vy-nsiL', - recipient_list: ['custom@email.com', 'email@test.com', 'test@email.com'], + recipient_list: [ + { recipient: 'custom@email.com' }, + { recipient: 'email@test.com' }, + { recipient: 'test@email.com' }, + ], email_group_id_list: [ '1y8ud3xO0KjvOyRonaFb', 'qm8rgKxOPmIl9Il-0ftu',