Skip to content

Commit

Permalink
fix: email module should not assume that eap alert class is required
Browse files Browse the repository at this point in the history
  • Loading branch information
gulfaraz committed Jul 1, 2024
1 parent 07ff5ed commit 0415d96
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion services/API-service/src/api/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ export class EventService {
event.eventName,
);
}
if (disasterSettings.eapAlertClasses) {
if (disasterType === DisasterType.Floods) {
// REFACTOR: either make eapAlertClass a requirement across all hazard
// types or reimplement such that eapAlertClass is not needed in the
// backend (it is a VIEW of the DATA in the dashboard and email)
event.disasterSpecificProperties = await this.getEventEapAlertClass(
disasterSettings,
event.triggerValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ export class EmailTemplateService {
CountryTimeZoneMapping[emailContent.country.countryCodeISO3],
triangleIcon: this.getTriangleIcon(event.eapAlertClass?.key),
leadTime: event.firstLeadTime.replace('-', ' '),
disasterIssuedLabel: event.eapAlertClass.label,
disasterIssuedLabel:
event.eapAlertClass?.label ?? event.triggerStatusLabel,
// REFACTOR: avoid the logic fork in disasterIssuedLabel
// use the same label variable across all hazard types
color: this.ibfColorToHex(event.eapAlertClass?.color),
advisory: this.getAdvisoryHtml(
event.triggerStatusLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class NotificationContentService {
disasterType,
event.eventName || 'no-name',
);
data.eapAlertClass = event.disasterSpecificProperties.eapAlertClass;
data.eapAlertClass = event.disasterSpecificProperties?.eapAlertClass;
return data;
}

Expand Down

0 comments on commit 0415d96

Please sign in to comment.