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

@ -26,7 +26,7 @@
{{ $t('general.cancel') }}
</sw-button>
<sw-button :loading="isLoading" variant="primary" type="submit">
<save-icon class="mr-2" v-if="!isLoading" />
<save-icon v-if="!isLoading" class="mr-2" />
{{ !isEdit ? $t('general.save') : $t('general.update') }}
</sw-button>
</div>
@ -90,6 +90,7 @@ export default {
methods: {
...mapActions('modal', ['closeModal', 'resetModalData']),
...mapActions('payment', ['addPaymentMode', 'updatePaymentMode']),
...mapActions('notification', ['showNotification']),
resetFormData() {
this.formData = {
id: null,
@ -108,27 +109,39 @@ export default {
if (this.isEdit) {
response = await this.updatePaymentMode(this.formData)
if (response.data) {
window.toastr['success'](
this.$t('settings.customization.payments.payment_mode_updated')
)
this.showNotification({
type: 'success',
message: this.$t(
'settings.customization.payments.payment_mode_updated'
),
})
this.refreshData ? this.refreshData() : ''
this.closePaymentModeModal()
return true
}
window.toastr['error'](response.data.error)
this.showNotification({
type: 'error',
message: response.data.error,
})
} else {
try {
response = await this.addPaymentMode(this.formData)
if (response.data) {
this.isLoading = false
window.toastr['success'](
this.$t('settings.customization.payments.payment_mode_added')
)
this.showNotification({
type: 'success',
message: this.$t(
'settings.customization.payments.payment_mode_added'
),
})
this.refreshData ? this.refreshData() : ''
this.closePaymentModeModal()
return true
}
window.toastr['error'](response.data.error)
this.showNotification({
type: 'error',
message: response.data.error,
})
} catch (err) {
this.isLoading = false
}