Fix customer samples create preview
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
William Buezas 2024-04-04 14:28:51 -03:00
parent 87f376464b
commit ec2604b9ab
1 changed files with 33 additions and 15 deletions

View File

@ -102,29 +102,43 @@ const setInitialData = () => {
sampleType.value = {}; sampleType.value = {};
}; };
const getPreview = async () => { const validateMessage = () => {
const { addressId, companyId, recipientId } = initialData; if (!initialData.recipient) return 'Email cannot be blank';
const path = `Clients/${route.params.id}/incoterms-authorization-html`; if (!sampleType.value) return 'Choose a sample';
const params = { if (sampleType.value.hasCompany && !initialData.companyFk) return 'Choose a company';
addressId, if (sampleType.value.datepickerEnabled && !initialData.from) return 'Choose a date';
companyId,
recipientId,
};
const queryParams = Object.keys(params)
.map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`)
.join('&');
const url = `${path}?${queryParams}`;
return '';
};
const setParams = (params) => {
if (sampleType.value.hasCompany) params.companyId = initialData.companyFk;
if (sampleType.value.datepickerEnabled) params.from = initialData.from;
if (initialData.addressId) params.addressId = initialData.addressId;
};
const getPreview = async () => {
try { try {
const { data } = await axios.get(url); const params = {
recipientId: route.params.id,
};
const validationMessage = validateMessage();
if (validationMessage) return notify(t(validationMessage), 'negative');
setParams(params);
const path = `${sampleType.value.model}/${route.params.id}/${sampleType.value.code}-html`;
const { data } = await axios.get(path, { params });
if (!data) return;
quasar.dialog({ quasar.dialog({
component: CustomerSamplesPreview, component: CustomerSamplesPreview,
componentProps: { componentProps: {
htmlContent: data, htmlContent: data,
}, },
}); });
} catch (error) { } catch (err) {
return error; notify('Errors getting preview', 'negative');
} }
}; };
@ -364,4 +378,8 @@ es:
To who should the recipient replay?: ¿A quien debería responder el destinatario? To who should the recipient replay?: ¿A quien debería responder el destinatario?
Edit address: Editar dirección Edit address: Editar dirección
Preview: Vista previa Preview: Vista previa
Email cannot be blank: Debes introducir un email
Choose a sample: Selecciona una plantilla
Choose a company: Selecciona una empresa
Choose a date: Selecciona una fecha
</i18n> </i18n>