Skip to content

Commit

Permalink
Merge pull request #901 from dpc-sdp/fix/r20-1585-unassigned-site-alert
Browse files Browse the repository at this point in the history
[R20-1585] Filter out alerts with missing type relation
  • Loading branch information
dylankelly authored Oct 18, 2023
2 parents 52575c5 + 528e65e commit 26cc4ae
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/nuxt-ripple/mapping/site/alerts/site-alerts-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@ const getAlertVariantForType = (
}

export const map = (src: TideApiResponse): TideAlert[] => {
const alerts = (src.site_alerts || []).map((rawAlert): TideAlert => {
const alertType = rawAlert.field_alert_type.name
const link = getLinkFromField(rawAlert, 'field_call_to_action')
const alerts = (src.site_alerts || [])
.filter((rawAlert: any) => rawAlert.field_alert_type)
.map((rawAlert: any) => {
const alertType = rawAlert.field_alert_type.name
const link = getLinkFromField(rawAlert, 'field_call_to_action')

return {
alertId: rawAlert.id,
variant: getAlertVariantForType(alertType),
iconName: getIconForType(alertType),
message: rawAlert.title || '',
linkText: link?.text || '',
linkUrl: link?.url || ''
}
})
return {
alertId: rawAlert.id,
variant: getAlertVariantForType(alertType),
iconName: getIconForType(alertType),
message: rawAlert.title || '',
linkText: link?.text || '',
linkUrl: link?.url || ''
}
})
return sortAlertsByPriority(alerts)
}

Expand Down

0 comments on commit 26cc4ae

Please sign in to comment.