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

@ -147,6 +147,11 @@ export default {
required,
},
},
watch: {
noteType() {
this.setFields()
},
},
async mounted() {
this.setFields()
if (this.modalDataID) {
@ -158,14 +163,10 @@ export default {
: (this.noteType = 'Invoice')
}
},
watch: {
noteType() {
this.setFields()
},
},
methods: {
...mapActions('modal', ['closeModal', 'resetModalData']),
...mapActions('notes', ['addNote', 'updateNote']),
...mapActions('notification', ['showNotification']),
...mapActions('invoice', {
setInvoiceNote: 'selectNote',
}),
@ -222,15 +223,19 @@ export default {
let res = await this.updateNote(data)
if (res.data) {
window.toastr['success'](
this.$t('settings.customization.notes.note_updated')
)
this.showNotification({
type: 'success',
message: this.$t('settings.customization.notes.note_updated'),
})
this.refreshData ? this.refreshData() : ''
this.closeNoteModal()
return true
}
window.toastr['error'](res.data.error)
this.showNotification({
type: 'error',
message: res.data.error,
})
} else {
try {
let data = {
@ -243,9 +248,10 @@ export default {
if (response.data && response.data.note) {
this.isLoading = false
window.toastr['success'](
this.$t('settings.customization.notes.note_added')
)
this.showNotification({
type: 'success',
message: this.$t('settings.customization.notes.note_added'),
})
if (
(this.$route.name === 'invoices.create' &&
response.data.note.type === 'Invoice') ||
@ -277,7 +283,10 @@ export default {
this.closeNoteModal()
return true
}
window.toastr['error'](response.data.error)
this.showNotification({
type: 'error',
message: response.data.error,
})
} catch (err) {
if (err.response.data.errors.name) {
this.isLoading = true