Add New SweetAlert & Notification Components

This commit is contained in:
Aman Upadhyay
2021-04-09 12:35:50 +00:00
committed by Mohit Panjwani
parent 3f7db2793f
commit c3d3e5e35f
78 changed files with 2295 additions and 984 deletions

View File

@ -423,6 +423,8 @@ export default {
...mapActions('customer', ['fetchCustomers']),
...mapActions('notification', ['showNotification']),
invoiceWithAmount({ invoice_number, due_amount }) {
return `${invoice_number} (${this.$utils.formatGraphMoney(
due_amount,
@ -561,25 +563,38 @@ export default {
this.$router.push(
`/admin/payments/${response.data.payment.id}/view`
)
window.toastr['success'](this.$t('payments.updated_message'))
this.showNotification({
type: 'success',
message: this.$t('payments.updated_message'),
})
return true
}
if (response.data.error === 'invalid_amount') {
window.toastr['error'](this.$t('invalid_amount_message'))
this.showNotification({
type: 'error',
message: this.$t('invalid_amount_message'),
})
return false
}
window.toastr['error'](response.data.error)
this.showNotification({
type: 'error',
message: response.data.error,
})
} catch (err) {
this.isLoading = false
if (err.response.data.errors.payment_number) {
window.toastr['error'](err.response.data.errors.payment_number)
this.showNotification({
type: 'error',
message: err.response.data.errors.payment_number,
})
return true
}
window.toastr['error'](err.response.data.message)
this.showNotification({
type: 'error',
message: err.response.data.message,
})
}
} else {
let data = {
@ -599,26 +614,39 @@ export default {
this.$router.push(
`/admin/payments/${response.data.payment.id}/view`
)
window.toastr['success'](this.$t('payments.created_message'))
this.showNotification({
type: 'success',
message: this.$t('payments.created_message'),
})
this.isLoading = true
return true
}
if (response.data.error === 'invalid_amount') {
window.toastr['error'](this.$t('invalid_amount_message'))
this.showNotification({
type: 'error',
message: this.$t('invalid_amount_message'),
})
return false
}
window.toastr['error'](response.data.error)
this.showNotification({
type: 'error',
message: response.data.error,
})
} catch (err) {
this.isLoading = false
if (err.response.data.errors.payment_number) {
window.toastr['error'](err.response.data.errors.payment_number)
this.showNotification({
type: 'error',
message: err.response.data.errors.payment_number,
})
return true
}
window.toastr['error'](err.response.data.message)
this.showNotification({
type: 'error',
message: err.response.data.message,
})
}
}
},