Skip to content

Commit

Permalink
Prettier email #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Haarhoff committed Jun 21, 2024
1 parent 566445b commit 1be82c7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
38 changes: 38 additions & 0 deletions src/commands/owner-agreement-invite/email-template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import mjml2html from 'mjml';

const agreementUrl = (publicUrl: string) =>
`${publicUrl}/members/sign-owner-agreement`;

export const textEmailTemplate = (publicUrl: string) =>
`You've been invited to sign the MakeSpace Owner Agreement. Please log in to the Members App (${publicUrl}) and visit ${agreementUrl(
publicUrl
)} to sign the agreement.`;

export const htmlEmailTemplate = (publicUrl: string) =>
mjml2html(`
<mjml>
<mj-body width="800px">
<mj-section background-color="#fa990e">
<mj-column>
<mj-text align="center" color="#111" font-size="40px">MakeSpace</mj-text>
<mj-text font-style="italic" align="center" color="#111" font-size="30px">Member App</mj-text>
</mj-column>
</mj-section>
<mj-section>
<mj-column width="400px">
<mj-text font-size="20px" line-height="1.3" color="#111" align="left">
<p>You've been invited to sign the MakeSpace Owner Agreement.</p>
<ol>
<li>Please log in to the <a href="${publicUrl}">Members App</a>.</li>
<li>Then view and sign the agreement.</li>
</ol>
</mj-text>
<mj-text color="#111"></mj-text>
<mj-button color="#111" background-color="#7FC436" href="${agreementUrl(
publicUrl
)}" font-weight="800">View Agreement</mj-button>
</mj-column>
</mj-section>
</mj-body>
</mjml>
`).html;
5 changes: 3 additions & 2 deletions src/commands/owner-agreement-invite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {readModels} from '../../read-models';
import {failureWithStatus} from '../../types/failureWithStatus';
import {StatusCodes} from 'http-status-codes';
import {Email, EmailAddress} from '../../types';
import {htmlEmailTemplate, textEmailTemplate} from './email-template';

const codec = t.strict({
recipient: tt.NumberFromString,
Expand All @@ -33,9 +34,9 @@ const constructEmail: SendEmail<OwnerAgreementInvite>['constructEmail'] = (
E.map(
(member): Email => ({
recipient: member.email as EmailAddress,
text: `You've been invited to sign the MakeSpace Owner Agreement. Please log in to the Members App (${conf.PUBLIC_URL}) and visit ${conf.PUBLIC_URL}/members/sign-owner-agreement to sign the agreement.`,
text: textEmailTemplate(conf.PUBLIC_URL),
subject: 'Sign the MS Owner Agreement',
html: `You've been invited to sign the MakeSpace Owner Agreement. Please log in to the Members App (${conf.PUBLIC_URL}) and visit ${conf.PUBLIC_URL}/members/sign-owner-agreement`,
html: htmlEmailTemplate(conf.PUBLIC_URL),
})
)
);
Expand Down
5 changes: 2 additions & 3 deletions src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {Dependencies} from './dependencies';
import {Config} from './configuration';
import {commands} from './commands';
import {commands, sendEmailCommands} from './commands';
import * as queries from './queries';
import {Route, get} from './types/route';
import {authRoutes} from './authentication';
import {queryToHandler, commandToHandlers, ping} from './http';
import {apiToHandlers} from './http/api-to-handlers';
import {emailHandler} from './http/email-handler';
import {ownerAgreementInvite} from './commands/owner-agreement-invite';

export const initRoutes = (
deps: Dependencies,
Expand Down Expand Up @@ -51,7 +50,7 @@ export const initRoutes = (
'sign-owner-agreement',
commands.members.signOwnerAgreement
),
email('owner-agreement-invite', ownerAgreementInvite),
email('owner-agreement-invite', sendEmailCommands.ownerAgreementInvite),
get('/ping', ping),
...authRoutes,
];
Expand Down

0 comments on commit 1be82c7

Please sign in to comment.