Skip to content

Commit 5875631

Browse files
eemaanamirarbrandes
authored andcommitted
refactor: updated code according to best practices
1 parent 176a95c commit 5875631

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

src/components/bulk-email-tool/bulk-email-task-manager/BulkEmailContentHistory.jsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,13 @@ function BulkEmailContentHistory({ intl }) {
5252
* display bug in the table.
5353
*/
5454
function transformDataForTable() {
55-
let tableData = [];
56-
if (emailHistoryData) {
57-
tableData = emailHistoryData.map((item) => {
58-
const [, day, year, time] = item.created.match(/(\d+), (\d+) at (.+) UTC/);
59-
const utcDateTimeString = `${year}-02-${day}T${time}Z`;
60-
const localDateTime = new Date(utcDateTimeString).toLocaleString();
61-
return {
62-
...item,
63-
subject: item.email.subject,
64-
sent_to: item.sent_to.join(', '),
65-
created: localDateTime,
66-
};
67-
});
68-
}
69-
return tableData;
55+
const tableData = emailHistoryData?.map((item) => ({
56+
...item,
57+
subject: item.email.subject,
58+
sent_to: item.sent_to.join(', '),
59+
created: new Date(item.created).toLocaleString(),
60+
}));
61+
return tableData || [];
7062
}
7163

7264
/**

src/components/bulk-email-tool/bulk-email-task-manager/BulkEmailTaskHistory.jsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@ function BulkEmailTaskHistory({ intl }) {
4242
}
4343

4444
function transformDataForTable() {
45-
let tableData = [];
46-
if (emailTaskHistoryData) {
47-
tableData = emailTaskHistoryData.map((item) => ({
48-
...item,
49-
created: new Date(item.created).toLocaleString(),
50-
}));
51-
}
52-
return tableData;
45+
const tableData = emailTaskHistoryData?.map((item) => ({
46+
...item,
47+
created: new Date(item.created).toLocaleString(),
48+
}));
49+
return tableData || [];
5350
}
5451

5552
const tableColumns = [

0 commit comments

Comments
 (0)