Skip to content

Commit 49cc7bf

Browse files
committed
update the email format type
1 parent c388095 commit 49cc7bf

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/utils/table.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,19 @@ export const initColumns = (columns: Column[], disableRichColumnHeaders?: boolea
255255
case ColumnFormat.EMAIL:
256256
c.cell = (row: any) => {
257257
const rowValue = getRowValueFromSelectorString(c.selector, row);
258-
const firstAuthor = rowValue.split(',')[0];
258+
const firstAuthor =
259+
typeof rowValue === 'string' && rowValue.includes(',') ? rowValue.split(',')[0] : '';
260+
let emailAddressPart = '';
261+
if (c && c.formatOptions && typeof row[c.formatOptions.emailAddressKey] === 'string') {
262+
const parts = row[c.formatOptions.emailAddressKey].split(':');
263+
emailAddressPart = parts.length > 1 ? parts[1] : '';
264+
}
259265
return (
260266
<a
261267
className="tag"
262268
href={
263-
hasFormatOptions && c.formatOptions.emailAddressKey
264-
? 'mailto:' +
265-
row[c.formatOptions.emailAddressKey].split(':')[1] +
266-
269+
emailAddressPart !== ''
270+
? 'mailto:' + emailAddressPart + ',[email protected]'
267271
: 'mailto:[email protected]'
268272
}
269273
onClick={(e) => e.stopPropagation()}
@@ -336,7 +340,7 @@ export const initColumns = (columns: Column[], disableRichColumnHeaders?: boolea
336340
}
337341
} else return null;
338342
};
339-
return c
343+
return c;
340344
case ColumnFormat.PUBLICATION:
341345
c.cell = (row: any) => {
342346
if (hasFormatOptions && c.formatOptions) {

0 commit comments

Comments
 (0)