diff --git a/src/commands/owner-agreement-invite/email-template.ts b/src/commands/owner-agreement-invite/email-template.ts new file mode 100644 index 00000000..173978f8 --- /dev/null +++ b/src/commands/owner-agreement-invite/email-template.ts @@ -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(` + + + + + MakeSpace + Member App + + + + + + You've been invited to sign the MakeSpace Owner Agreement. + + Please log in to the Members App. + Then view and sign the agreement. + + + + View Agreement + + + + + `).html; diff --git a/src/commands/owner-agreement-invite/index.ts b/src/commands/owner-agreement-invite/index.ts index dafb1f9d..7b7d9e5a 100644 --- a/src/commands/owner-agreement-invite/index.ts +++ b/src/commands/owner-agreement-invite/index.ts @@ -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, @@ -33,9 +34,9 @@ const constructEmail: SendEmail['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), }) ) ); diff --git a/src/routes.ts b/src/routes.ts index 38fe4788..cd6b96b1 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -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, @@ -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, ];
You've been invited to sign the MakeSpace Owner Agreement.