diff --git a/package.json b/package.json
index 477ce09c..d02ec5de 100644
--- a/package.json
+++ b/package.json
@@ -34,14 +34,13 @@
"lodash": "^4.17.13",
"moment": "^2.29.1",
"sweet-modal-vue": "^2.0.0",
- "sweetalert": "^2.1.2",
"tailwindcss": "^2.0.1",
- "toastr": "^2.1.4",
"v-tooltip": "^2.0.2",
"vue": "^2.6.10",
"vue-i18n": "^8.22.0",
"vue-loader": "^15.9.3",
"vue-router": "2.7.0",
+ "vue-sweetalert2": "^4.2.1",
"vue2-transitions": "^0.3.0",
"vuedraggable": "^2.24.2",
"vuelidate": "^0.6.2",
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js
index 244da98f..622bf512 100644
--- a/resources/assets/js/app.js
+++ b/resources/assets/js/app.js
@@ -8,7 +8,6 @@ import router from './router.js'
import store from './store/index'
import utils from './helpers/utilities'
import i18n from './plugins/i18n'
-import swal from 'sweetalert'
require('./bootstrap')
@@ -27,5 +26,4 @@ new Vue({
router,
store,
i18n,
- swal,
}).$mount('#app')
diff --git a/resources/assets/js/bootstrap.js b/resources/assets/js/bootstrap.js
index bb10eaea..956283ec 100644
--- a/resources/assets/js/bootstrap.js
+++ b/resources/assets/js/bootstrap.js
@@ -8,6 +8,8 @@ import money from 'v-money'
import VTooltip from 'v-tooltip'
import Transitions from 'vue2-transitions'
import SpaceWind from '@bytefury/spacewind'
+import swal from 'vue-sweetalert2'
+import 'sweetalert2/dist/sweetalert2.min.css'
/**
* Theme
@@ -22,6 +24,33 @@ Vue.use(SpaceWind, { theme })
Vue.use(Vuelidate)
+Vue.use(swal, {
+ customClass: {
+ container:
+ 'fixed z-50 inset-0 overflow-y-auto bg-black bg-opacity-25 flex justify-center min-h-screen items-center sm:p-0 swal2-container',
+ popup:
+ 'flex items-center flex-col justify-center align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full sm:p-6',
+ header: 'swal2-header',
+ title: 'swal2-title',
+ closeButton: '',
+ icon: 'swal2-icon',
+ image: '',
+ content: 'swal2-content',
+ input: '',
+ inputLabel: '',
+ validationMessage: '',
+ actions: 'swal2-actions',
+ confirmButton:
+ 'w-full inline-flex py-2 px-4 text-sm leading-5 rounded items-center justify-center text-white font-normal transition duration-150 ease-in-out border border-transparent focus:outline-none bg-primary-500 hover:bg-opacity-75 whitespace-nowrap',
+ denyButton: '',
+ cancelButton:
+ 'w-full inline-flex py-2 px-4 text-sm leading-5 rounded justify-center items-center focus:outline-none font-normal transition ease-in-out duration-150 border border-transparent border border-solid border-primary-500 text-primary-500 hover:bg-primary-200 shadow-inner whitespace-nowrap',
+ loader: '',
+ footer: '',
+ },
+ buttonsStyling: false,
+})
+
Vue.use(Transitions)
window._ = require('lodash')
@@ -89,10 +118,11 @@ global.axios.interceptors.response.use(undefined, function (err) {
return true
}
if (!err.response) {
- window.toastr['error'](
- 'Please check your internet connection or wait until servers are back online',
- 'Network Error'
- )
+ store.dispatch('notification/showNotification', {
+ type: 'error',
+ message:
+ 'Please check your internet connection or wait until servers are back online.',
+ })
} else {
if (
err.response.data &&
@@ -100,24 +130,30 @@ global.axios.interceptors.response.use(undefined, function (err) {
err.response.data === ' Unauthorized.')
) {
// Unauthorized and log out
- window.toastr['error'](
- err.response.data.message ? err.response.data.message : 'Unauthorized'
- )
+ store.dispatch('notification/showNotification', {
+ type: 'error',
+ message: err.response.data.message
+ ? err.response.data.message
+ : 'Unauthorized',
+ })
store.dispatch('auth/logout', true)
} else if (err.response.data.errors) {
// Show a notification per error
const errors = JSON.parse(JSON.stringify(err.response.data.errors))
for (const i in errors) {
- window.toastr['error'](errors[i])
+ store.dispatch('notification/showNotification', {
+ type: 'error',
+ message: errors[i],
+ })
}
} else {
// Unknown error
- window.toastr['error'](
- err.response.data.message
+ store.dispatch('notification/showNotification', {
+ type: 'error',
+ message: err.response.data.message
? err.response.data.message
: err.response.data || 'Unknown error occurred',
- 'Error'
- )
+ })
}
}
return Promise.reject(err)
@@ -126,8 +162,6 @@ global.axios.interceptors.response.use(undefined, function (err) {
/**
* Global plugins
*/
-window.toastr = require('toastr')
-
Vue.use(VueRouter)
Vue.use(Vuex)
Vue.use(VTooltip)
diff --git a/resources/assets/js/components/base/BaseNotification.vue b/resources/assets/js/components/base/BaseNotification.vue
new file mode 100644
index 00000000..5d3da964
--- /dev/null
+++ b/resources/assets/js/components/base/BaseNotification.vue
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+
+ {{
+ notificationTitle ? notificationTitle : success ? 'Success!' : 'Error'
+ }}
+
+
+ {{
+ notificationMessage
+ ? notificationMessage
+ : success
+ ? 'Successful'
+ : 'Somthing went wrong'
+ }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/assets/js/components/base/index.js b/resources/assets/js/components/base/index.js
index e377c461..dc636bd4 100644
--- a/resources/assets/js/components/base/index.js
+++ b/resources/assets/js/components/base/index.js
@@ -13,6 +13,7 @@ import NoteSelectPopup from './popup/NoteSelectPopup.vue'
import BaseDatePicker from '../base/BaseDatePicker.vue'
import BaseTimePicker from './BaseTimePicker.vue'
import BasePage from './BasePage.vue'
+import BaseNotification from './BaseNotification.vue'
import GlobalSearch from '../GlobalSearch.vue'
@@ -39,6 +40,7 @@ Vue.component('tax-select-popup', TaxSelectPopup)
Vue.component('note-select-popup', NoteSelectPopup)
Vue.component('base-time-picker', BaseTimePicker)
+Vue.component('base-notification', BaseNotification)
Vue.component('dot-icon', DotIcon)
Vue.component('save-icon', SaveIcon)
diff --git a/resources/assets/js/components/base/modal/BackupModal.vue b/resources/assets/js/components/base/modal/BackupModal.vue
index 33645195..5f275fc0 100644
--- a/resources/assets/js/components/base/modal/BackupModal.vue
+++ b/resources/assets/js/components/base/modal/BackupModal.vue
@@ -2,8 +2,8 @@
@@ -376,6 +376,7 @@ export default {
'fetchCustomField',
]),
...mapActions('modal', ['closeModal']),
+ ...mapActions('notification', ['showNotification']),
resetFormData() {
this.formData = {
label: null,
@@ -433,9 +434,10 @@ export default {
if (this.isEdit) {
this.isLoading = true
response = await this.updateCustomField(data)
- window.toastr['success'](
- this.$tc('settings.custom_fields.updated_message')
- )
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('settings.custom_fields.updated_message'),
+ })
this.refreshData()
this.closeCategoryModal()
return true
@@ -444,7 +446,10 @@ export default {
this.isLoading = true
response = await this.addCustomField(data)
- window.toastr['success'](this.$tc('settings.custom_fields.added_message'))
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('settings.custom_fields.added_message'),
+ })
this.refreshData()
this.closeCategoryModal()
return true
diff --git a/resources/assets/js/components/base/modal/CustomerModal.vue b/resources/assets/js/components/base/modal/CustomerModal.vue
index d00fd915..4b43510f 100644
--- a/resources/assets/js/components/base/modal/CustomerModal.vue
+++ b/resources/assets/js/components/base/modal/CustomerModal.vue
@@ -62,7 +62,7 @@
:allow-empty="false"
:show-labels="false"
:placeholder="$t('customers.select_currency')"
- :maxHeight="200"
+ :max-height="200"
label="name"
class="mt-1 md:mt-0"
track-by="id"
@@ -343,7 +343,7 @@
>
{{ $t('general.cancel') }}
-
+
{{ $t('general.save') }}
@@ -444,6 +444,8 @@ export default {
...mapGetters(['currencies', 'countries']),
...mapGetters('company', ['defaultCurrency']),
...mapGetters('modal', ['modalDataID', 'modalData', 'modalActive']),
+ ...mapActions('notification', ['showNotification']),
+
nameError() {
if (!this.$v.formData.name.$error) {
return ''
@@ -586,6 +588,7 @@ export default {
'updateCustomer',
]),
...mapActions('modal', ['closeModal']),
+ ...mapActions('notification', ['showNotification']),
resetData() {
this.formData = {
name: null,
@@ -700,9 +703,15 @@ export default {
}
if (response.data) {
if (this.modalDataID) {
- window.toastr['success'](this.$tc('customers.updated_message'))
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('customers.updated_message'),
+ })
} else {
- window.toastr['success'](this.$tc('customers.created_message'))
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('customers.created_message'),
+ })
}
this.isLoading = false
diff --git a/resources/assets/js/components/base/modal/FileDiskModal.vue b/resources/assets/js/components/base/modal/FileDiskModal.vue
index 7ae9cfdb..e1e78a16 100644
--- a/resources/assets/js/components/base/modal/FileDiskModal.vue
+++ b/resources/assets/js/components/base/modal/FileDiskModal.vue
@@ -5,9 +5,9 @@
:is="selected_disk"
:loading="isLoading"
:disks="getDiskDrivers"
+ :is-edit="isEdit"
@on-change-disk="(disk) => (selected_disk = disk.value)"
@submit="createNewDisk"
- :is-edit="isEdit"
>
{{ $t('general.cancel') }}
@@ -96,6 +96,8 @@ export default {
...mapActions('modal', ['closeModal']),
+ ...mapActions('notification', ['showNotification']),
+
isRequestFire(slotProps) {
return slotProps && (slotProps.diskData.isLoading || this.isLoading)
},
@@ -131,14 +133,21 @@ export default {
this.refreshData()
this.closeDisk()
if (this.isEdit) {
- window.toastr['success'](this.$t('settings.disk.success_update'))
+ this.showNotification({
+ type: 'success',
+ message: this.$t('settings.disk.success_update'),
+ })
} else {
- window.toastr['success'](this.$t('settings.disk.success_create'))
+ this.showNotification({
+ type: 'success',
+ message: this.$t('settings.disk.success_create'),
+ })
}
} else {
- window.toastr['error'](
- this.$t('settings.disk.invalid_disk_credentials')
- )
+ this.showNotification({
+ type: 'error',
+ message: this.$t('settings.disk.invalid_disk_credentials'),
+ })
}
this.isLoading = false
},
diff --git a/resources/assets/js/components/base/modal/ItemModal.vue b/resources/assets/js/components/base/modal/ItemModal.vue
index e517b9d2..e2bcca91 100644
--- a/resources/assets/js/components/base/modal/ItemModal.vue
+++ b/resources/assets/js/components/base/modal/ItemModal.vue
@@ -251,6 +251,7 @@ export default {
...mapActions('modal', ['closeModal', 'resetModalData']),
...mapActions('item', ['addItem', 'updateItem', 'fetchItemUnits']),
...mapActions('invoice', ['setItem']),
+ ...mapActions('notification', ['showNotification']),
resetFormData() {
this.formData = {
@@ -304,7 +305,10 @@ export default {
response = await this.addItem(data)
}
if (response.data) {
- window.toastr['success'](this.$tc('items.created_message'))
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('items.created_message'),
+ })
this.setItem(response.data.item)
window.hub.$emit('newItem', response.data.item)
@@ -314,7 +318,10 @@ export default {
this.closeModal()
return true
}
- window.toastr['error'](response.data.error)
+ this.showNotification({
+ type: 'error',
+ message: response.data.error,
+ })
},
closeItemModal() {
diff --git a/resources/assets/js/components/base/modal/ItemUnitModal.vue b/resources/assets/js/components/base/modal/ItemUnitModal.vue
index bf0fcc1d..11058b17 100755
--- a/resources/assets/js/components/base/modal/ItemUnitModal.vue
+++ b/resources/assets/js/components/base/modal/ItemUnitModal.vue
@@ -97,6 +97,7 @@ export default {
methods: {
...mapActions('modal', ['closeModal', 'resetModalData']),
...mapActions('item', ['addItemUnit', 'updateItemUnit', 'fatchItemUnit']),
+ ...mapActions('notification', ['showNotification']),
resetFormData() {
this.formData = {
id: null,
@@ -123,13 +124,17 @@ export default {
if (response.data) {
this.isLoading = false
if (!this.isEdit) {
- window.toastr['success'](
- this.$t('settings.customization.items.item_unit_added')
- )
+ this.showNotification({
+ type: 'success',
+ message: this.$t('settings.customization.items.item_unit_added'),
+ })
} else {
- window.toastr['success'](
- this.$t('settings.customization.items.item_unit_updated')
- )
+ this.showNotification({
+ type: 'success',
+ message: this.$t(
+ 'settings.customization.items.item_unit_updated'
+ ),
+ })
}
this.refreshData ? this.refreshData() : ''
this.closeItemUnitModal()
@@ -137,7 +142,10 @@ export default {
}
} catch (error) {
this.isLoading = false
- window.toastr['error'](response.data.error)
+ this.showNotification({
+ type: 'error',
+ message: response.data.error,
+ })
}
},
async setData() {
diff --git a/resources/assets/js/components/base/modal/MailTestModal.vue b/resources/assets/js/components/base/modal/MailTestModal.vue
index 3f92e159..75d67982 100644
--- a/resources/assets/js/components/base/modal/MailTestModal.vue
+++ b/resources/assets/js/components/base/modal/MailTestModal.vue
@@ -4,8 +4,8 @@
@@ -19,8 +19,8 @@
@@ -33,8 +33,8 @@
@@ -57,7 +57,7 @@
>
{{ $t('general.cancel') }}
-
+
{{ !isEdit ? $t('general.send') : $t('general.update') }}
@@ -149,6 +149,7 @@ export default {
methods: {
...mapActions('modal', ['closeModal', 'resetModalData']),
...mapActions('company', ['sendTestMail']),
+ ...mapActions('notification', ['showNotification']),
resetFormData() {
this.formData = {
to: null,
@@ -169,18 +170,26 @@ export default {
if (response.data) {
if (response.data.success) {
- window.toastr['success'](this.$tc('general.send_mail_successfully'))
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('general.send_mail_successfully'),
+ })
this.closeTaxModal()
this.isLoading = false
return true
}
-
- window.toastr['error'](this.$tc('validation.something_went_wrong'))
+ this.showNotification({
+ type: 'error',
+ message: this.$tc('validation.something_went_wrong'),
+ })
this.closeTaxModal()
this.isLoading = false
return true
}
- window.toastr['error'](response.data.error)
+ this.showNotification({
+ type: 'error',
+ message: response.data.error,
+ })
},
closeTaxModal() {
this.resetModalData()
diff --git a/resources/assets/js/components/base/modal/NoteModal.vue b/resources/assets/js/components/base/modal/NoteModal.vue
index ad5a71fc..3d41625d 100755
--- a/resources/assets/js/components/base/modal/NoteModal.vue
+++ b/resources/assets/js/components/base/modal/NoteModal.vue
@@ -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
diff --git a/resources/assets/js/components/base/modal/PaymentModeModal.vue b/resources/assets/js/components/base/modal/PaymentModeModal.vue
index a23c01aa..38dc8b2f 100755
--- a/resources/assets/js/components/base/modal/PaymentModeModal.vue
+++ b/resources/assets/js/components/base/modal/PaymentModeModal.vue
@@ -26,7 +26,7 @@
{{ $t('general.cancel') }}
-
+
{{ !isEdit ? $t('general.save') : $t('general.update') }}
@@ -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
}
diff --git a/resources/assets/js/components/base/modal/SendEstimateModal.vue b/resources/assets/js/components/base/modal/SendEstimateModal.vue
index b0801a99..67bb3b58 100644
--- a/resources/assets/js/components/base/modal/SendEstimateModal.vue
+++ b/resources/assets/js/components/base/modal/SendEstimateModal.vue
@@ -61,8 +61,8 @@
v-model="formData.body"
:fields="estimateMailFields"
:invalid="$v.formData.body.$error"
- @input="$v.formData.body.$touch()"
class="mt-2"
+ @input="$v.formData.body.$touch()"
/>
@@ -140,6 +140,7 @@ export default {
computed: {
...mapGetters('modal', ['modalDataID', 'modalData', 'modalActive']),
...mapGetters('user', ['currentUser']),
+ ...mapActions('notification', ['showNotification']),
getEmailUrl() {
return this.url
},
@@ -224,15 +225,31 @@ export default {
if (this.$v.$invalid) {
return true
}
- swal({
+ this.$swal({
title: this.$t('general.are_you_sure'),
text: this.$t('estimates.confirm_send_estimate'),
- icon: '/assets/icon/check-circle-solid.svg',
- buttons: true,
- dangerMode: true,
- }).then(async (value) => {
+ icon: 'question',
+ iconHtml: ``,
+ showCancelButton: true,
+ showConfirmButton: true,
+ }).then(async (result) => {
try {
- if (value) {
+ if (result.value) {
let data = {
...this.formData,
id: this.modalDataID,
@@ -244,21 +261,26 @@ export default {
this.closeModal()
if (res.data.success) {
this.isLoading = false
- window.toastr['success'](
- this.$tc('estimates.send_estimate_successfully')
- )
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('estimates.send_estimate_successfully'),
+ })
return true
}
if (res.data.error === 'estimates.user_email_does_not_exist') {
- window.toastr['error'](
- this.$tc('estimates.user_email_does_not_exist')
- )
+ this.showNotification({
+ type: 'error',
+ message: this.$tc('estimates.user_email_does_not_exist'),
+ })
return false
}
}
} catch (error) {
this.isLoading = false
- window.toastr['error'](this.$tc('estimates.something_went_wrong'))
+ this.showNotification({
+ type: 'error',
+ message: this.$tc('estimates.something_went_wrong'),
+ })
}
})
},
diff --git a/resources/assets/js/components/base/modal/SendInvoiceModal.vue b/resources/assets/js/components/base/modal/SendInvoiceModal.vue
index d88dd7d4..d15bff30 100644
--- a/resources/assets/js/components/base/modal/SendInvoiceModal.vue
+++ b/resources/assets/js/components/base/modal/SendInvoiceModal.vue
@@ -55,8 +55,8 @@
v-model="formData.body"
:fields="InvoiceMailFields"
:invalid="$v.formData.body.$error"
- @input="$v.formData.body.$touch()"
class="mt-2"
+ @input="$v.formData.body.$touch()"
/>
@@ -194,6 +194,8 @@ export default {
...mapActions('company', ['fetchCompanySettings', 'fetchMailConfig']),
+ ...mapActions('notification', ['showNotification']),
+
async setInitialData() {
let admin = await this.fetchMailConfig()
@@ -220,15 +222,31 @@ export default {
if (this.$v.$invalid) {
return true
}
- swal({
+ this.$swal({
title: this.$t('general.are_you_sure'),
text: this.$t('invoices.confirm_send_invoice'),
- icon: '/assets/icon/check-circle-solid.svg',
- buttons: true,
- dangerMode: true,
- }).then(async (value) => {
+ icon: 'question',
+ iconHtml: ``,
+ showCancelButton: true,
+ showConfirmButton: true,
+ }).then(async (result) => {
try {
- if (value) {
+ if (result.value) {
let data = {
...this.formData,
id: this.modalDataID,
@@ -239,21 +257,26 @@ export default {
this.closeModal()
if (res.data.success) {
this.isLoading = false
- window.toastr['success'](
- this.$tc('invoices.send_invoice_successfully')
- )
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('invoices.send_invoice_successfully'),
+ })
return true
}
if (res.data.error === 'invoices.user_email_does_not_exist') {
- window.toastr['error'](
- this.$tc('invoices.user_email_does_not_exist')
- )
+ this.showNotification({
+ type: 'error',
+ message: this.$tc('invoices.user_email_does_not_exist'),
+ })
return false
}
}
} catch (error) {
this.isLoading = false
- window.toastr['error'](this.$tc('invoices.something_went_wrong'))
+ this.showNotification({
+ type: 'error',
+ message: this.$tc('invoices.something_went_wrong'),
+ })
}
})
},
diff --git a/resources/assets/js/components/base/modal/SendPaymentModal.vue b/resources/assets/js/components/base/modal/SendPaymentModal.vue
index e47ecae6..d6e8c9fb 100644
--- a/resources/assets/js/components/base/modal/SendPaymentModal.vue
+++ b/resources/assets/js/components/base/modal/SendPaymentModal.vue
@@ -4,9 +4,9 @@
@@ -188,6 +188,8 @@ export default {
...mapActions('company', ['fetchCompanySettings', 'fetchMailConfig']),
+ ...mapActions('notification', ['showNotification']),
+
async setInitialData() {
let admin = await this.fetchMailConfig()
@@ -216,15 +218,31 @@ export default {
if (this.$v.$invalid) {
return true
}
- swal({
+ this.$swal({
title: this.$t('general.are_you_sure'),
text: this.$t('payments.confirm_send_payment'),
- icon: '/assets/icon/check-circle-solid.svg',
- buttons: true,
- dangerMode: true,
- }).then(async (value) => {
+ icon: 'question',
+ iconHtml: `
`,
+ showCancelButton: true,
+ showConfirmButton: true,
+ }).then(async (result) => {
try {
- if (value) {
+ if (result.value) {
let data = {
...this.formData,
id: this.modalDataID,
@@ -236,21 +254,26 @@ export default {
this.closeModal()
if (res.data.success) {
this.isLoading = false
- window.toastr['success'](
- this.$tc('payments.send_payment_successfully')
- )
+ this.showNotification({
+ type: 'success',
+ message: this.$tc('payments.send_payment_successfully'),
+ })
return true
}
if (res.data.error === 'payments.user_email_does_not_exist') {
- window.toastr['error'](
- this.$tc('payments.user_email_does_not_exist')
- )
+ this.showNotification({
+ type: 'error',
+ message: this.$tc('payments.user_email_does_not_exist'),
+ })
return false
}
}
} catch (error) {
this.isLoading = false
- window.toastr['error'](this.$tc('payments.something_went_wrong'))
+ this.showNotification({
+ type: 'error',
+ message: this.$tc('payments.something_went_wrong'),
+ })
}
})
},
diff --git a/resources/assets/js/components/base/modal/SetDefaultDiskModal.vue b/resources/assets/js/components/base/modal/SetDefaultDiskModal.vue
index fa5f3081..d2cdd14b 100644
--- a/resources/assets/js/components/base/modal/SetDefaultDiskModal.vue
+++ b/resources/assets/js/components/base/modal/SetDefaultDiskModal.vue
@@ -9,9 +9,9 @@
:searchable="true"
:allow-empty="false"
:show-labels="false"
+ :custom-label="getCustomLabel"
class="mt-2"
track-by="id"
- :custom-label="getCustomLabel"
/>
@@ -90,6 +90,8 @@ export default {
...mapActions('modal', ['closeModal']),
+ ...mapActions('notification', ['showNotification']),
+
async loadData() {
this.loading = true
@@ -107,7 +109,10 @@ export default {
if (response.data.success) {
this.refreshData()
this.closeDisk()
- window.toastr['success'](this.$t('settings.disk.success'))
+ this.showNotification({
+ type: 'success',
+ message: this.$t('settings.disk.success'),
+ })
}
this.isLoading = true
},
diff --git a/resources/assets/js/components/base/modal/TaxTypeModal.vue b/resources/assets/js/components/base/modal/TaxTypeModal.vue
index 434e79bf..b0c83861 100644
--- a/resources/assets/js/components/base/modal/TaxTypeModal.vue
+++ b/resources/assets/js/components/base/modal/TaxTypeModal.vue
@@ -69,7 +69,7 @@
{{ $t('general.cancel') }}
-
+
{{ !isEdit ? $t('general.save') : $t('general.update') }}
@@ -174,6 +174,7 @@ export default {
methods: {
...mapActions('modal', ['closeModal', 'resetModalData']),
...mapActions('taxType', ['addTaxType', 'updateTaxType', 'fetchTaxType']),
+ ...mapActions('notification', ['showNotification']),
resetFormData() {
this.formData = {
id: null,
@@ -198,13 +199,15 @@ export default {
}
if (response.data) {
if (!this.isEdit) {
- window.toastr['success'](
- this.$t('settings.tax_types.created_message')
- )
+ this.showNotification({
+ type: 'success',
+ message: this.$t('settings.tax_types.created_message'),
+ })
} else {
- window.toastr['success'](
- this.$t('settings.tax_types.updated_message')
- )
+ this.showNotification({
+ type: 'success',
+ message: this.$t('settings.tax_types.updated_message'),
+ })
}
window.hub.$emit('newTax', response.data.taxType)
this.refreshData ? this.refreshData() : ''
@@ -212,7 +215,10 @@ export default {
this.isLoading = false
return true
}
- window.toastr['error'](response.data.error)
+ this.showNotification({
+ type: 'error',
+ message: response.data.error,
+ })
},
async setData() {
this.formData = {
diff --git a/resources/assets/js/store/index.js b/resources/assets/js/store/index.js
index 6daae75a..a27d209f 100644
--- a/resources/assets/js/store/index.js
+++ b/resources/assets/js/store/index.js
@@ -26,6 +26,7 @@ import estimateTemplate from './modules/estimate-template'
import invoiceTemplate from './modules/invoice-template'
import search from './modules/search'
import notes from './modules/notes'
+import notification from './modules/notification'
Vue.use(Vuex)
@@ -76,5 +77,6 @@ export default new Vuex.Store({
invoiceTemplate,
search,
notes,
+ notification,
},
})
diff --git a/resources/assets/js/store/modules/auth/actions.js b/resources/assets/js/store/modules/auth/actions.js
index 1851377f..198d70f4 100644
--- a/resources/assets/js/store/modules/auth/actions.js
+++ b/resources/assets/js/store/modules/auth/actions.js
@@ -13,7 +13,6 @@ export const login = ({ commit }, data) => {
commit('user/' + userTypes.RESET_CURRENT_USER, null, { root: true })
commit(rootTypes.UPDATE_APP_LOADING_STATUS, false, { root: true })
- window.toastr['success']('Login Successful')
resolve(response)
})
.catch((err) => {
@@ -28,7 +27,7 @@ export const setLogoutFalse = ({ state, commit }) => {
commit(types.SET_LOGOUT, false)
}
-export const logout = ({ state, commit }) => {
+export const logout = ({ state, commit, dispatch }) => {
return new Promise((resolve, reject) => {
if (state.isLoggedOut) {
resolve()
@@ -40,7 +39,14 @@ export const logout = ({ state, commit }) => {
.get('/auth/logout')
.then(() => {
router.push('/login')
- window.toastr['success']('Logged out!', 'Success')
+ dispatch(
+ 'notification/showNotification',
+ {
+ type: 'success',
+ message: 'Logged out successfully.',
+ },
+ { root: true }
+ )
})
.catch((err) => {
router.push('/login')
diff --git a/resources/assets/js/store/modules/notification/actions.js b/resources/assets/js/store/modules/notification/actions.js
new file mode 100644
index 00000000..4f0f0f0b
--- /dev/null
+++ b/resources/assets/js/store/modules/notification/actions.js
@@ -0,0 +1,27 @@
+import * as types from './mutation-types'
+
+export const showNotification = ({ commit, dispatch, state }, payload) => {
+ commit(types.SHOW_NOTIFICATION, true)
+
+ if (payload.type) {
+ commit(types.SET_NOTIFICATION_TYPE, payload.type)
+ }
+ if (payload.title) {
+ commit(types.SET_TITLE, payload.title)
+ }
+ if (payload.autoHide) {
+ commit(types.SET_AUTO_HIDE, payload.autoHide)
+ }
+ if (payload.message) {
+ commit(types.SET_MESSAGE, payload.message)
+ }
+}
+
+export const hideNotification = ({ commit, dispatch, state }) => {
+ commit(types.RESET_DATA)
+ commit(types.HIDE_NOTIFICATION, false)
+}
+
+export const resetNotificationData = ({ commit, dispatch, state }) => {
+ commit(types.RESET_DATA)
+}
diff --git a/resources/assets/js/store/modules/notification/getters.js b/resources/assets/js/store/modules/notification/getters.js
new file mode 100644
index 00000000..0d3859f0
--- /dev/null
+++ b/resources/assets/js/store/modules/notification/getters.js
@@ -0,0 +1,5 @@
+export const notificationActive = (state) => state.active
+export const notificationTitle = (state) => state.title
+export const notificationMessage = (state) => state.message
+export const notificationAutoHide = (state) => state.autoHide
+export const notificationType = (state) => state.type
diff --git a/resources/assets/js/store/modules/notification/index.js b/resources/assets/js/store/modules/notification/index.js
new file mode 100644
index 00000000..3cf25f2c
--- /dev/null
+++ b/resources/assets/js/store/modules/notification/index.js
@@ -0,0 +1,23 @@
+import mutations from './mutations'
+import * as actions from './actions'
+import * as getters from './getters'
+
+const initialState = {
+ active: false,
+ autoHide: true,
+ title: '',
+ message: '',
+ type: '',
+}
+
+export default {
+ namespaced: true,
+
+ state: initialState,
+
+ getters: getters,
+
+ actions: actions,
+
+ mutations: mutations,
+}
diff --git a/resources/assets/js/store/modules/notification/mutation-types.js b/resources/assets/js/store/modules/notification/mutation-types.js
new file mode 100644
index 00000000..d2def41d
--- /dev/null
+++ b/resources/assets/js/store/modules/notification/mutation-types.js
@@ -0,0 +1,7 @@
+export const SHOW_NOTIFICATION = 'SHOW_NOTIFICATION'
+export const HIDE_NOTIFICATION = 'HIDE_NOTIFICATION'
+export const SET_TITLE = 'SET_TITLE'
+export const SET_AUTO_HIDE = 'SET_AUTO_HIDE'
+export const SET_MESSAGE = 'SET_MESSAGE'
+export const SET_NOTIFICATION_TYPE = 'SET_NOTIFICATION_TYPE'
+export const RESET_DATA = 'RESET_DATA'
diff --git a/resources/assets/js/store/modules/notification/mutations.js b/resources/assets/js/store/modules/notification/mutations.js
new file mode 100644
index 00000000..d864bb38
--- /dev/null
+++ b/resources/assets/js/store/modules/notification/mutations.js
@@ -0,0 +1,33 @@
+import * as types from './mutation-types'
+
+export default {
+ [types.SHOW_NOTIFICATION](state, data) {
+ state.active = data
+ },
+
+ [types.HIDE_NOTIFICATION](state, data) {
+ state.active = data
+ },
+
+ [types.SET_TITLE](state, data) {
+ state.title = data
+ },
+
+ [types.SET_AUTO_HIDE](state, data) {
+ state.autoHide = data
+ },
+
+ [types.SET_MESSAGE](state, data) {
+ state.message = data
+ },
+
+ [types.SET_NOTIFICATION_TYPE](state, data) {
+ state.type = data
+ },
+
+ [types.RESET_DATA](state) {
+ state.active = false
+ state.description = ''
+ state.title = ''
+ },
+}
diff --git a/resources/assets/js/views/auth/ForgotPassword.vue b/resources/assets/js/views/auth/ForgotPassword.vue
index bca0ecbe..bc10ee7a 100644
--- a/resources/assets/js/views/auth/ForgotPassword.vue
+++ b/resources/assets/js/views/auth/ForgotPassword.vue
@@ -45,9 +45,8 @@