add mail sender in setting

This commit is contained in:
yashkanakiya
2023-03-11 18:58:59 +05:30
parent b4aa254b68
commit 959aa257b4
23 changed files with 1718 additions and 110 deletions

View File

@ -256,6 +256,31 @@
/> </template
></BaseInput>
</BaseInputGroup>
<!-- && setPasswordMethod !== 'manual' -->
<BaseInputGroup
v-show="customerStore.currentCustomer.enable_portal"
:label="$t('customers.select_sender')"
class="pt-5"
:error="
v$.currentCustomer.mail_sender_id.$error &&
v$.currentCustomer.mail_sender_id.$errors[0].$message
"
:content-loading="isFetchingInitialData"
required
>
<BaseMultiselect
v-model="customerStore.currentCustomer.mail_sender_id"
label="name"
value-prop="id"
:options="mailSenderStore.mailSenders"
:can-deselect="false"
:can-clear="false"
searchable
track-by="name"
:invalid="v$.currentCustomer.mail_sender_id.$error"
@input="v$.currentCustomer.mail_sender_id.$touch()"
/>
</BaseInputGroup>
</BaseInputGrid>
</div>
@ -601,11 +626,13 @@ import CustomerCustomFields from '@/scripts/admin/components/custom-fields/Creat
import { useGlobalStore } from '@/scripts/admin/stores/global'
import CopyInputField from '@/scripts/admin/components/CopyInputField.vue'
import { useCompanyStore } from '@/scripts/admin/stores/company'
import { useMailSenderStore } from '@/scripts/admin/stores/mail-sender'
const customerStore = useCustomerStore()
const customFieldStore = useCustomFieldStore()
const globalStore = useGlobalStore()
const companyStore = useCompanyStore()
const mailSenderStore = useMailSenderStore()
const customFieldValidationScope = 'customFields'
@ -617,6 +644,7 @@ const route = useRoute()
let isFetchingInitialData = ref(false)
let isShowPassword = ref(false)
let isShowConfirmPassword = ref(false)
const mailSenders = ref(null)
let active = ref(false)
const isSaving = ref(false)
@ -679,6 +707,9 @@ const rules = computed(() => {
website: {
url: helpers.withMessage(t('validation.invalid_url'), url),
},
mail_sender_id: {
required: helpers.withMessage(t('validation.required'), required),
},
billing: {
address_street_1: {
maxLength: helpers.withMessage(
@ -722,6 +753,20 @@ const v$ = useVuelidate(rules, customerStore, {
$scope: customFieldValidationScope,
})
onMounted(async () => {
await mailSenderStore.fetchMailSenders()
let mailSenderData = await mailSenderStore.fetchMailSenderList()
if (mailSenderData.data) {
mailSenders.value = mailSenderData.data.data
let defaultMailSender = mailSenderData.data.data.find(
(mailSender) => mailSender.is_default == true
)
customerStore.currentCustomer.mail_sender_id = defaultMailSender
? defaultMailSender.id
: null
}
})
customerStore.resetCurrentCustomer()
customerStore.fetchCustomerInitialSettings(isEdit.value)