From b29a56d7ddcb855239308df488fa9dfedb41753b Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 4 Sep 2024 14:37:39 +0200 Subject: [PATCH 1/4] refs #6943 remake, refactor, clean code Samples --- .../components/CustomerSamplesCreate.vue | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/pages/Customer/components/CustomerSamplesCreate.vue b/src/pages/Customer/components/CustomerSamplesCreate.vue index 0470dc176..50a2c17d5 100644 --- a/src/pages/Customer/components/CustomerSamplesCreate.vue +++ b/src/pages/Customer/components/CustomerSamplesCreate.vue @@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'; import { useRoute, useRouter } from 'vue-router'; import axios from 'axios'; +import { usePrintService } from 'composables/usePrintService'; import { useQuasar } from 'quasar'; import { useState } from 'src/composables/useState'; @@ -27,7 +28,7 @@ const router = useRouter(); const state = useState(); const user = state.getUser(); const stateStore = useStateStore(); - +const { sendEmail } = usePrintService(); const client = ref({}); const hasChanged = ref(false); const isLoading = ref(false); @@ -156,22 +157,25 @@ const onSubmit = async () => { } }; -const onDataSaved = async ({ - addressId, - companyFk, - companyId, - from, - recipient, - replyTo, -}) => { - await axios.post(`Clients/${route.params.id}/incoterms-authorization-email`, { - addressId, - companyFk, - companyId, - from, - recipient, - replyTo, +const getSamples = async () => { + const filter = { where: { id: initialData.typeFk } }; + let { data } = await axios.get('Samples', { + params: { filter: JSON.stringify(filter) }, }); + return data[0]; +}; + +getSamples(); +const onDataSaved = async () => { + const params = { + recipientId: initialData.recipientId, + recipient: initialData.recipient, + replyTo: initialData.replyTo, + }; + setParams(params); + const samplesData = await getSamples(); + const path = `${samplesData.model}/${route.params.id}/${samplesData.code}-email`; + await sendEmail(path, params); toCustomerSamples(); }; @@ -327,7 +331,6 @@ const toCustomerSamples = () => { option-value="id" required="true" v-model="initialData.addressId" - v-if="sampleType.id === 20" >