refs #6943 remake, refactor, clean code Samples #677
|
@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { usePrintService } from 'composables/usePrintService';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
|
@ -27,7 +28,7 @@ const router = useRouter();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
const { sendEmail } = usePrintService();
|
||||||
const client = ref({});
|
const client = ref({});
|
||||||
const hasChanged = ref(false);
|
const hasChanged = ref(false);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
@ -156,22 +157,33 @@ const onSubmit = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDataSaved = async ({
|
const getSamples = async () => {
|
||||||
addressId,
|
try {
|
||||||
companyFk,
|
const filter = { where: { id: initialData.typeFk } };
|
||||||
companyId,
|
let { data } = await axios.get('Samples', {
|
||||||
from,
|
params: { filter: JSON.stringify(filter) },
|
||||||
recipient,
|
});
|
||||||
carlossa marked this conversation as resolved
Outdated
|
|||||||
replyTo,
|
return data[0];
|
||||||
}) => {
|
} catch (error) {
|
||||||
await axios.post(`Clients/${route.params.id}/incoterms-authorization-email`, {
|
notify('errors.create', 'negative');
|
||||||
addressId,
|
}
|
||||||
companyFk,
|
};
|
||||||
companyId,
|
|
||||||
from,
|
getSamples();
|
||||||
recipient,
|
const onDataSaved = async () => {
|
||||||
replyTo,
|
try {
|
||||||
});
|
const params = {
|
||||||
|
recipientId: initialData.recipientId,
|
||||||
|
recipient: initialData.recipient,
|
||||||
|
replyTo: initialData.replyTo,
|
||||||
carlossa marked this conversation as resolved
Outdated
jsegarra
commented
try/catch? try/catch?
|
|||||||
|
};
|
||||||
|
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();
|
toCustomerSamples();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Si falla la peticion o data es nullo, que pasará?