Skip to content

Commit

Permalink
Fix recipient_list format for Email Channel in frontend to match back…
Browse files Browse the repository at this point in the history
…end (#385)

Signed-off-by: Mohammad Qureshi <[email protected]>
  • Loading branch information
qreshi authored Mar 24, 2022
1 parent 6c56aa9 commit 9f4a56b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion public/pages/CreateChannel/__tests__/helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ describe('constructs and deconstructs email objects', () => {
'recipient-group-id-2',
'recipient-group-id-3',
],
recipient_list: ['[email protected]', '[email protected]'],
recipient_list: [
{ recipient: '[email protected]' },
{ recipient: '[email protected]' },
],
};

it('constructs email objects', () => {
Expand Down
4 changes: 2 additions & 2 deletions public/pages/CreateChannel/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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!,
Expand Down
12 changes: 10 additions & 2 deletions test/mocks/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ const mockEmail: ChannelItemType = {
is_enabled: true,
email: {
email_account_id: 'dj8etXkBCzVy9Vy-nsiL',
recipient_list: ['[email protected]', '[email protected]', '[email protected]'],
recipient_list: [
{ recipient: '[email protected]' },
{ recipient: '[email protected]' },
{ recipient: '[email protected]' },
],
email_group_id_list: [
'1l8hq3kB0XwiBlEbanSo',
'dz8etXkBCzVy9Vy-0sgh',
Expand Down Expand Up @@ -76,7 +80,11 @@ const mockEmailWithSES: ChannelItemType = {
is_enabled: true,
email: {
email_account_id: 'dj8etXkBCzVy9Vy-nsiL',
recipient_list: ['[email protected]', '[email protected]', '[email protected]'],
recipient_list: [
{ recipient: '[email protected]' },
{ recipient: '[email protected]' },
{ recipient: '[email protected]' },
],
email_group_id_list: [
'1y8ud3xO0KjvOyRonaFb',
'qm8rgKxOPmIl9Il-0ftu',
Expand Down

0 comments on commit 9f4a56b

Please sign in to comment.