0
0
Fork 0

Merge pull request 'refs #6943 remake, refactor, clean code Samples' (!677) from 6943-fixCustomerSamples into master

Reviewed-on: verdnatura/salix-front#677
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
Carlos Satorres 2024-09-05 09:57:20 +00:00
commit 1662e3b459
1 changed files with 29 additions and 17 deletions

View File

@ -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,33 @@ 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 () => {
try {
const filter = { where: { id: initialData.typeFk } };
let { data } = await axios.get('Samples', {
params: { filter: JSON.stringify(filter) },
});
return data[0];
} catch (error) {
notify('errors.create', 'negative');
}
};
getSamples();
const onDataSaved = async () => {
try {
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);
} catch (error) {
notify('errors.create', 'negative');
}
toCustomerSamples();
};