pcpuma_unam_operador/plugins/inject.js

76 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-07-11 01:06:30 +00:00
const alertsGenericos = {
imprimirError(
buefy,
err = {},
title = '¡Hubo un error!',
onConfirm = () => {}
) {
buefy.dialog.alert({
ariaModal: true,
hasIcon: true,
onConfirm,
ariaRole: 'alertdialog',
confirmText: 'Entendido',
icon: 'alert-octagon',
iconPack: 'mdi',
message: err.message,
title,
type: 'is-danger',
})
// if (err.err && err.err === 'token error') {
// localStorage.clear()
// this.$router.push('/')
// }
},
imprimirMensaje(
buefy,
message,
onConfirm = () => {},
title = '¡Felicidades!'
) {
buefy.dialog.alert({
ariaModal: true,
hasIcon: true,
onConfirm,
ariaRole: 'alertdialog',
confirmText: 'Ok',
icon: 'check-circle',
iconPack: 'mdi',
message,
title,
type: 'is-success',
})
},
imprimirWarning(
buefy,
message,
onConfirm = () => {},
title = '¡Espera un minuto!',
onCancel = () => {}
) {
buefy.dialog.alert({
ariaModal: true,
canCancel: true,
hasIcon: true,
onCancel,
onConfirm,
ariaRole: 'alertdialog',
cancelText: 'Cancelar',
confirmText: 'Confirmar',
icon: 'help-circle',
iconPack: 'mdi',
message,
title,
type: 'is-warning',
})
},
getLocalhostInfo() {
const objeto = JSON.parse(localStorage.getItem('usuario'))
this.admin = objeto.operador
},
}
export default ({ app }, inject) => {
inject('alertsGenericos', alertsGenericos)
}