Skip to content

Commit

Permalink
WIP add notification-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
arsforza committed Aug 2, 2024
1 parent a59d889 commit 123a690
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,6 @@ export class EmailTemplateService {
}),
);
}
console.log(
'🚀 ~ EmailTemplateService ~ getMjmlEventListBody ~ eventList:',
eventList,
);
return eventList;
}

Expand Down
12 changes: 11 additions & 1 deletion services/API-service/src/api/notification/email/mjml.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import mjml2html from 'mjml';
import { ContentEventEmail } from '../dto/content-trigger-email.dto';
import { EmailTemplateService } from './email-template.service';
import { getMjmlHeader } from './mjml/header';
import { getMjmlNotificationAction } from './mjml/notification-actions';

@Injectable()
export class MjmlService {
Expand Down Expand Up @@ -39,13 +40,22 @@ export class MjmlService {
const bodyEventList =
this.emailTemplateService.getMjmlEventListBody(emailContent);

const notificationAction = getMjmlNotificationAction({
linkDashboard: process.env.DASHBOARD_URL,
linkEapSop: emailContent.linkEapSop,
socialMediaLink:
emailContent.country.notificationInfo.linkSocialMediaUrl ?? '',
socialMediaType:
emailContent.country.notificationInfo.linkSocialMediaType ?? '',
});

const emailObject = {
tagName: 'mjml',
attributes: {},
children: [
{
tagName: 'mj-body',
children: [header, ...bodyEventList],
children: [header, ...bodyEventList, notificationAction],
},
],
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
export const getMjmlNotificationAction = ({
linkDashboard,
linkEapSop,
socialMediaLink,
socialMediaType,
}: {
linkDashboard: string;
linkEapSop: string;
socialMediaLink: string;
socialMediaType: string;
}): object => {
const ibfPortalRow = getNotificationActionsSection(
'Go to the IBF-portal',
linkDashboard,
'Find more information about the potentially exposed areas, view the map and manage anticipatory actions.',
);

const socialMediaRow = getNotificationActionsSection(
`Join ${socialMediaType} group`,
socialMediaLink,
'Communicate with relevant others about the trigger.',
);

const aboutTriggerRow = getNotificationActionsSection(
`About Trigger`,
linkEapSop,
'Read about the trigger methodology and the anticipatory actions.',
);

return {
tagName: 'mj-section',
children: [
{
tagName: 'mj-column',
children: [ibfPortalRow, socialMediaRow, aboutTriggerRow],
},
],
};
};

const getNotificationActionsSection = (
buttonText: string,
buttonLink: string,
descriptionn: string,
): object => {
return {
tagName: 'mj-section',
children: [
{
tagName: 'mj-column',
children: [
{
tagName: 'mj-button',
attributes: { href: buttonLink },
content: buttonText,
},
],
},
{
tagName: 'mj-column',
children: [
{
tagName: 'mj-text',
content: descriptionn,
},
],
},
],
};
};

0 comments on commit 123a690

Please sign in to comment.