Skip to content

Commit

Permalink
feat: created util to sort alert messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rickimoore committed Jul 12, 2023
1 parent c4a7859 commit f3e2b5a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/utilities/sortAlerts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AlertMessage, StatusColor } from '../types'

const sortAlertMessagesBySeverity = (alertMessages: AlertMessage[]): AlertMessage[] => {
const severityOrder: StatusColor[] = [
StatusColor.ERROR,
StatusColor.WARNING,
StatusColor.SUCCESS,
StatusColor.DARK,
]

return alertMessages.sort((a, b) => {
const aSeverityIndex = severityOrder.indexOf(a.severity)
const bSeverityIndex = severityOrder.indexOf(b.severity)
return aSeverityIndex - bSeverityIndex
})
}

export default sortAlertMessagesBySeverity

0 comments on commit f3e2b5a

Please sign in to comment.