Skip to content

Commit

Permalink
alert-store: Create abstracted functions for pushing specific alert l…
Browse files Browse the repository at this point in the history
…evels
  • Loading branch information
rafaellehmkuhl committed Feb 1, 2024
1 parent 2b1a21b commit 9b478f0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/stores/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ export const useAlertStore = defineStore('alert', () => {
}
}

const pushSuccessAlert = (message: string, time_created: Date = new Date()): void => {
pushAlert(new Alert(AlertLevel.Success, message, time_created))
}
const pushErrorAlert = (message: string, time_created: Date = new Date()): void => {
pushAlert(new Alert(AlertLevel.Error, message, time_created))
}
const pushInfoAlert = (message: string, time_created: Date = new Date()): void => {
pushAlert(new Alert(AlertLevel.Info, message, time_created))
}
const pushWarningAlert = (message: string, time_created: Date = new Date()): void => {
pushAlert(new Alert(AlertLevel.Warning, message, time_created))
}
const pushCriticalAlert = (message: string, time_created: Date = new Date()): void => {
pushAlert(new Alert(AlertLevel.Critical, message, time_created))
}

// Alert speech syntesis routine
const synth = window.speechSynthesis

Expand Down Expand Up @@ -129,5 +145,10 @@ export const useAlertStore = defineStore('alert', () => {
availableAlertSpeechVoiceNames,
sortedAlerts,
pushAlert,
pushSuccessAlert,
pushErrorAlert,
pushInfoAlert,
pushWarningAlert,
pushCriticalAlert,
}
})

0 comments on commit 9b478f0

Please sign in to comment.