Skip to content

Commit

Permalink
refactor: more appropriate email template structure (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-w committed Mar 13, 2024
1 parent 4837334 commit fbf6abf
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ export class MailSenderService {
const { name, email, inviteUrl, spaceName } = info;
return {
subject: `${name} (${email}) invited you to their space ${spaceName} - ${this.baseConfig.brandName}`,
template: 'invite',
template: 'normal',
context: {
name,
email,
spaceName,
inviteUrl,
partialBody: 'invite',
},
};
}
Expand All @@ -56,23 +57,23 @@ export class MailSenderService {
fromUserName,
refRecord: { baseId, tableId, fieldName, tableName, recordIds },
} = info;
let subject, template;
let subject, partialBody;
const refLength = recordIds.length;

const viewRecordUrlPrefix = `${this.mailConfig.origin}/base/${baseId}/${tableId}`;

if (refLength <= 1) {
subject = `${fromUserName} added you to the ${fieldName} field of a record in ${tableName}`;
template = 'collaborator-cell-tag';
partialBody = 'collaborator-cell-tag';
} else {
subject = `${fromUserName} added you to ${refLength} records in ${tableName}`;
template = 'collaborator-multi-row-tag';
partialBody = 'collaborator-multi-row-tag';
}

return {
notifyMessage: subject,
subject: `${subject} - ${this.baseConfig.brandName}`,
template,
template: 'normal',
context: {
notifyId,
fromUserName,
Expand All @@ -81,6 +82,7 @@ export class MailSenderService {
fieldName,
recordIds,
viewRecordUrlPrefix,
partialBody,
},
};
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,8 @@
border="0" cellpadding="0" cellspacing="0">
<!-- Header -->
{{> header }}

<!-- Body -->
<tr>
<td style="padding: 30px; text-align: center;">
<h2 style="margin: 0;">Invitation to Collaborate</h2>
<p style="margin: 18px 0;"><strong>{{name}}</strong> ({{email}}) has invited you to
collaborate
on their space <strong>{{spaceName}}</strong>.</p>
<a href="{{inviteUrl}}" class="button"
style="background-color: #22bc66; color: #ffffff; padding: 12px 24px; border-radius: 5px; text-decoration: none; font-weight: bold; display: inline-block; margin: 20px 0;">Accept
Invitation</a>
</td>
</tr>

<!-- Boby -->
{{> (lookup . 'partialBody') }}
<!-- Footer -->
{{> footer }}
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<tr>
<td style="padding: 30px; text-align: center;">
<p style="margin: 18px 0;">
<strong>{{fromUserName}}</strong> added you to the <strong>{{fieldName}}</strong> field of a
record
in
<strong>{{tableName}}</strong>.
</p>
<a
href="{{viewRecordUrlPrefix}}?recordId={{lookup recordIds 0}}&fromNotify={{notifyId}}"
class="button"
style="
padding: 12px 24px;
margin: 20px 0;
background-color: rgb(24, 24, 27);
color: rgb(250, 250, 250);
border-radius: 5px;
text-decoration: none;
font-weight: bold;
display: inline-block;
"
>View record
</a>
</td>
</tr>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<tr>
<td style="padding: 30px; text-align: center;">
<p style="margin: 18px 0;">
<strong>{{fromUserName}}</strong> added you to {{refLength}} records in
<strong>{{tableName}}</strong>:
</p>
{{#each recordIds}}
The <strong>{{../fieldName}}</strong> field of a record:
<a
href="{{../viewRecordUrlPrefix}}?recordId={{this}}&fromNotify={{../notifyId}}"
target="_blank"
style="color:#3276dc"
>{{../viewRecordUrlPrefix}}?recordId={{this}}&fromNotify={{../notifyId}}
</a>
<br>
<br>
{{/each}}
</td>
</tr>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<tr>
<td style="padding: 30px; text-align: center;">
<h2 style="margin: 0;">Invitation to Collaborate</h2>
<p style="margin: 18px 0;"><strong>{{name}}</strong> ({{email}}) has invited you to
collaborate
on their space <strong>{{spaceName}}</strong>.</p>
<a href="{{inviteUrl}}" class="button"
style="background-color: rgb(24, 24, 27); color: rgb(250, 250, 250); padding: 12px 24px; border-radius: 5px; text-decoration: none; font-weight: bold; display: inline-block; margin: 20px 0;">Accept
Invitation</a>
</td>
</tr>

0 comments on commit fbf6abf

Please sign in to comment.