Skip to content

useAlert ​

Triggers a global alert notification by committing to the Vuex alert store module.

File: vue/src/js/hooks/useAlert.js


Usage ​

js
import { useAlert } from '@/hooks'

const { openAlert } = useAlert()

openAlert({ message: 'Saved successfully', variant: 'success' })
openAlert({ message: 'Something went wrong', variant: 'error' })

Returns ​

NameTypeDescription
openAlert(payload) => voidCommit an alert to the store

Payload ​

KeyTypeDescription
messageStringAlert message text
variantString'success' | 'error' | 'warning' | 'info'
locationStringOptional. Vuetify snackbar location, e.g. 'top'

Notes ​

  • The alert is rendered by the global snackbar component that reads from store.state.alert.
  • useItemActions and table hooks call openAlert internally after server actions complete.

See Also ​