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

@ -0,0 +1,147 @@
<template>
<transition
enter-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2 "
enter-active-class="transition duration-300 ease-out transform"
enter-to-class="duration-300 translate-y-0 opacity-100 sm:translate-x-0"
leave-active-class="transition duration-100 ease-in"
leave-class="duration-200 opacity-100"
leave-to-class="duration-200 opacity-0"
>
<div
v-if="notificationActive"
class="fixed inset-0 z-50 flex items-end justify-center px-4 py-6 pointer-events-none sm:p-6 sm:items-start sm:justify-end"
>
<div
:class="success || info ? 'bg-white' : 'bg-red-50'"
class="w-full max-w-sm rounded-lg shadow-lg cursor-pointer pointer-events-auto"
@click="hideNotification"
>
<div class="overflow-hidden rounded-lg shadow-xs">
<div class="p-4">
<div class="flex items-start">
<div class="flex-shrink-0">
<svg
v-if="success"
class="w-6 h-6 text-green-400"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
<exclamation-circle-icon
v-if="info"
class="w-6 h-6 text-blue-400"
/>
<svg
v-if="error"
class="w-6 h-6 text-red-400"
fill="currentColor"
viewBox="0 0 24 24"
>
<path
fill-rule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"
clip-rule="evenodd"
/>
</svg>
</div>
<div class="flex-1 w-0 ml-3">
<p
:class="`text-sm leading-5 font-medium ${
success || info ? 'text-gray-900' : 'text-red-800'
}`"
>
{{
notificationTitle ? notificationTitle : success ? 'Success!' : 'Error'
}}
</p>
<p
:class="`mt-1 text-sm leading-5 ${
success || info ? 'text-gray-500' : 'text-red-700'
}`"
>
{{
notificationMessage
? notificationMessage
: success
? 'Successful'
: 'Somthing went wrong'
}}
</p>
</div>
<div class="flex flex-shrink-0">
<button
:class="
success || info
? ' text-gray-400 focus:text-gray-500'
: 'text-red-400 focus:text-red-500'
"
class="inline-flex w-5 h-5 transition duration-150 ease-in-out focus:outline-none"
@click="hideNotification"
>
<x-icon />
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</transition>
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
import { XIcon } from '@vue-hero-icons/outline'
import { ExclamationCircleIcon } from '@vue-hero-icons/solid'
export default {
components: {
XIcon,
ExclamationCircleIcon,
},
data() {
return {
hasFocus: false,
}
},
computed: {
...mapGetters('notification', [
'notificationActive',
'notificationTitle',
'notificationType',
'notificationAutoHide',
'notificationMessage',
]),
success() {
return this.notificationType.toLowerCase() === 'success'
},
error() {
return this.notificationType.toLowerCase() === 'error'
},
info() {
return this.notificationType.toLowerCase() === 'info'
},
},
watch: {
notificationActive(val) {
if (val && this.notificationAutoHide) {
window.setTimeout(this.hideNotification, 5000)
}
},
},
mounted() {
if (this.notificationActive && this.notificationAutoHide) {
window.setTimeout(this.hideNotification, 5000)
}
},
methods: {
...mapActions('notification', ['showNotification', 'hideNotification']),
},
}
</script>

View File

@ -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)

View File

@ -2,8 +2,8 @@
<div class="relative customer-modal">
<base-loader
v-if="isRequestOngoing"
class="h-130"
:show-bg-overlay="true"
class="h-130"
/>
<form @submit.prevent="createNewBackup">
<div class="p-6">
@ -21,7 +21,7 @@
:show-labels="false"
:placeholder="$t('settings.backup.select_backup_type')"
:allow-empty="false"
:maxHeight="100"
:max-height="100"
/>
</sw-input-group>
<sw-input-group
@ -38,11 +38,11 @@
:show-labels="false"
:placeholder="$t('settings.disk.select_disk')"
:allow-empty="false"
track-by="id"
:preselect-first="true"
:custom-label="getCustomLabel"
:maxHeight="100"
:max-height="100"
:loading="isLoading"
track-by="id"
/>
</sw-input-group>
</div>
@ -59,9 +59,9 @@
</sw-button>
<sw-button
:loading="isCreateLoading"
:disabled="isCreateLoading"
variant="primary"
type="submit"
:disabled="isCreateLoading"
>
<save-icon v-if="!isCreateLoading" class="mr-2" />
{{ $t('general.create') }}
@ -140,6 +140,8 @@ export default {
...mapActions('modal', ['closeModal']),
...mapActions('notification', ['showNotification']),
getCustomLabel({ driver, name }) {
return `${name} — [${driver}]`
},
@ -154,12 +156,18 @@ export default {
this.isCreateLoading = true
await this.createBackup(data)
this.isCreateLoading = false
window.toastr['success'](this.$t('settings.backup.created_message'))
this.showNotification({
type: 'success',
message: this.$t('settings.backup.created_message'),
})
this.refreshData ? this.refreshData() : ''
this.cancelBackup()
} catch (e) {
this.isCreateLoading = false
window.toastr['error'](e.response.data.message)
this.showNotification({
type: 'error',
message: e.response.data.message,
})
}
},

View File

@ -41,7 +41,7 @@
>
{{ $t('general.cancel') }}
</sw-button>
<sw-button variant="primary" type="submit" :loading="isLoading">
<sw-button :loading="isLoading" variant="primary" type="submit">
<save-icon v-if="!isLoading" class="mr-2" />
{{ !isEdit ? $t('general.save') : $t('general.update') }}
</sw-button>
@ -135,6 +135,8 @@ export default {
methods: {
...mapActions('modal', ['closeModal']),
...mapActions('category', ['addCategory', 'updateCategory']),
...mapActions('notification', ['showNotification']),
resetFormData() {
this.formData = {
id: null,
@ -159,13 +161,15 @@ export default {
if (response.data) {
if (!this.isEdit) {
window.toastr['success'](
this.$t('settings.expense_category.created_message')
)
this.showNotification({
type: 'success',
message: this.$t('settings.expense_category.created_message'),
})
} else {
window.toastr['success'](
this.$t('settings.expense_category.updated_message')
)
this.showNotification({
type: 'success',
message: this.$t('settings.expense_category.updated_message'),
})
}
window.hub.$emit('newCategory', response.data.category)
this.refreshData ? this.refreshData() : ''
@ -173,7 +177,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 = {

View File

@ -78,9 +78,9 @@
/>
</sw-input-group>
<sw-input-group
v-if="isDropdownSelected"
:label="$t('settings.custom_fields.options')"
class="mt-5"
v-if="isDropdownSelected"
horizontal
>
<option-create @onAdd="addNewOptions" />
@ -92,28 +92,28 @@
>
<sw-input v-model="option.name" type="text" style="width: 90%" />
<minus-circle-icon
@click="removeOption(index)"
class="ml-1 cursor-pointer icon text-danger"
@click="removeOption(index)"
/>
</div>
</sw-input-group>
<sw-input-group
v-if="formData.type"
:label="$t('settings.custom_fields.default_value')"
horizontal
class="relative mt-5"
v-if="formData.type"
>
<component
:value="formData.default_answer"
:is="formData.type + 'Type'"
:options="formData.options"
:defaultDateTime="formData.dateTimeValue"
:default-date-time="formData.dateTimeValue"
v-model="formData.default_answer"
/>
</sw-input-group>
<sw-input-group
:label="$t('settings.custom_fields.placeholder')"
v-if="!isSwitchTypeSelected"
:label="$t('settings.custom_fields.placeholder')"
class="mt-5"
horizontal
>
@ -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

View File

@ -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') }}
</sw-button>
<sw-button variant="primary" type="submit" :loading="isLoading">
<sw-button :loading="isLoading" variant="primary" type="submit">
<save-icon v-if="!isLoading" class="mr-2" />
{{ $t('general.save') }}
</sw-button>
@ -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

View File

@ -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"
>
<template v-slot="slotProps">
<div
@ -16,15 +16,15 @@
<sw-button
class="mr-3 text-sm"
variant="primary-outline"
@click="closeDisk"
type="button"
@click="closeDisk"
>
{{ $t('general.cancel') }}
</sw-button>
<sw-button
:loading="isRequestFire(slotProps)"
variant="primary"
:disabled="isRequestFire(slotProps)"
variant="primary"
type="submit"
>
<save-icon v-if="!isRequestFire(slotProps)" class="mr-2" />
@ -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
},

View File

@ -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() {

View File

@ -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() {

View File

@ -4,8 +4,8 @@
<div class="p-4 md:p-8">
<sw-input-group
:label="$t('general.to')"
class="mt-3"
:error="emailError"
class="mt-3"
variant="horizontal"
required
>
@ -19,8 +19,8 @@
</sw-input-group>
<sw-input-group
:label="$t('general.subject')"
class="mt-3"
:error="subjectError"
class="mt-3"
variant="horizontal"
required
>
@ -33,8 +33,8 @@
</sw-input-group>
<sw-input-group
:label="$t('general.message')"
class="mt-3"
:error="messageError"
class="mt-3"
variant="horizontal"
required
>
@ -57,7 +57,7 @@
>
{{ $t('general.cancel') }}
</sw-button>
<sw-button variant="primary" type="submit" :loading="isLoading">
<sw-button :loading="isLoading" variant="primary" type="submit">
<paper-airplane-icon v-if="!isLoading" class="mr-2" />
{{ !isEdit ? $t('general.send') : $t('general.update') }}
</sw-button>
@ -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()

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

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
}

View File

@ -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()"
/>
</sw-input-group>
</div>
@ -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: `<svg
aria-hidden="true"
class="w-6 h-6"
focusable="false"
data-prefix="fas"
data-icon="check-circle"
class="svg-inline--fa fa-check-circle fa-w-16"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path
fill="#55547A"
d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"
></path>
</svg>`,
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'),
})
}
})
},

View File

@ -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()"
/>
</sw-input-group>
</div>
@ -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: `<svg
aria-hidden="true"
class="w-6 h-6"
focusable="false"
data-prefix="fas"
data-icon="check-circle"
class="svg-inline--fa fa-check-circle fa-w-16"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path
fill="#55547A"
d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"
></path>
</svg>`,
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'),
})
}
})
},

View File

@ -4,9 +4,9 @@
<div class="px-8 py-8 sm:p-6">
<sw-input-group
:label="$t('general.from')"
:error="fromError"
class="mb-4"
variant="vertical"
:error="fromError"
required
>
<sw-input
@ -25,8 +25,8 @@
>
<sw-input
v-model="formData.to"
type="text"
:invalid="$v.formData.to.$error"
type="text"
@input="$v.formData.to.$touch()"
/>
</sw-input-group>
@ -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: `<svg
aria-hidden="true"
class="w-6 h-6"
focusable="false"
data-prefix="fas"
data-icon="check-circle"
class="svg-inline--fa fa-check-circle fa-w-16"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path
fill="#55547A"
d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"
></path>
</svg>`,
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'),
})
}
})
},

View File

@ -9,9 +9,9 @@
:searchable="true"
:allow-empty="false"
:show-labels="false"
:custom-label="getCustomLabel"
class="mt-2"
track-by="id"
:custom-label="getCustomLabel"
/>
</sw-input-group>
</div>
@ -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
},

View File

@ -69,7 +69,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>
@ -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 = {