diff --git a/src/components/EditPictureForm.vue b/src/components/EditPictureForm.vue index cd6107aca..1f158e785 100644 --- a/src/components/EditPictureForm.vue +++ b/src/components/EditPictureForm.vue @@ -156,26 +156,22 @@ const rotateRight = () => { }; const onSubmit = () => { - try { - if (!newPhoto.files && !newPhoto.url) { - notify(t('Select an image'), 'negative'); - return; - } - - const options = { - type: 'blob', - }; - - editor.value - .result(options) - .then((result) => { - const file = new File([result], newPhoto.files?.name || ''); - newPhoto.blob = file; - }) - .then(() => makeRequest()); - } catch (err) { - console.error('Error uploading image'); + if (!newPhoto.files && !newPhoto.url) { + notify(t('Select an image'), 'negative'); + return; } + + const options = { + type: 'blob', + }; + + editor.value + .result(options) + .then((result) => { + const file = new File([result], newPhoto.files?.name || ''); + newPhoto.blob = file; + }) + .then(() => makeRequest()); }; const makeRequest = async () => { diff --git a/src/components/EditTableCellValueForm.vue b/src/components/EditTableCellValueForm.vue index 14709e884..7755df9ab 100644 --- a/src/components/EditTableCellValueForm.vue +++ b/src/components/EditTableCellValueForm.vue @@ -51,21 +51,17 @@ const onDataSaved = () => { }; const onSubmit = async () => { - try { - isLoading.value = true; - const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk })); - const payload = { - field: selectedField.value.field, - newValue: newValue.value, - lines: rowsToEdit, - }; + isLoading.value = true; + const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk })); + const payload = { + field: selectedField.value.field, + newValue: newValue.value, + lines: rowsToEdit, + }; - await axios.post($props.editUrl, payload); - onDataSaved(); - isLoading.value = false; - } catch (err) { - console.error('Error submitting table cell edit'); - } + await axios.post($props.editUrl, payload); + onDataSaved(); + isLoading.value = false; }; const closeForm = () => { diff --git a/src/components/FilterItemForm.vue b/src/components/FilterItemForm.vue index 1cf36deeb..5c3d47415 100644 --- a/src/components/FilterItemForm.vue +++ b/src/components/FilterItemForm.vue @@ -84,34 +84,30 @@ const tableColumns = computed(() => [ ]); const onSubmit = async () => { - try { - let filter = itemFilter; - const params = itemFilterParams; - const where = {}; - for (let key in params) { - const value = params[key]; - if (!value) continue; + let filter = itemFilter; + const params = itemFilterParams; + const where = {}; + for (let key in params) { + const value = params[key]; + if (!value) continue; - switch (key) { - case 'name': - where[key] = { like: `%${value}%` }; - break; - case 'producerFk': - case 'typeFk': - case 'size': - case 'inkFk': - where[key] = value; - } + switch (key) { + case 'name': + where[key] = { like: `%${value}%` }; + break; + case 'producerFk': + case 'typeFk': + case 'size': + case 'inkFk': + where[key] = value; } - filter.where = where; - - const { data } = await axios.get(props.url, { - params: { filter: JSON.stringify(filter) }, - }); - tableRows.value = data; - } catch (err) { - console.error('Error fetching entries items'); } + filter.where = where; + + const { data } = await axios.get(props.url, { + params: { filter: JSON.stringify(filter) }, + }); + tableRows.value = data; }; const closeForm = () => { diff --git a/src/components/FilterTravelForm.vue b/src/components/FilterTravelForm.vue index c84772d9b..6eb44bd01 100644 --- a/src/components/FilterTravelForm.vue +++ b/src/components/FilterTravelForm.vue @@ -86,32 +86,28 @@ const tableColumns = computed(() => [ ]); const onSubmit = async () => { - try { - let filter = travelFilter; - const params = travelFilterParams; - const where = {}; - for (let key in params) { - const value = params[key]; - if (!value) continue; + let filter = travelFilter; + const params = travelFilterParams; + const where = {}; + for (let key in params) { + const value = params[key]; + if (!value) continue; - switch (key) { - case 'agencyModeFk': - case 'warehouseInFk': - case 'warehouseOutFk': - case 'shipped': - case 'landed': - where[key] = value; - } + switch (key) { + case 'agencyModeFk': + case 'warehouseInFk': + case 'warehouseOutFk': + case 'shipped': + case 'landed': + where[key] = value; } - - filter.where = where; - const { data } = await axios.get('Travels', { - params: { filter: JSON.stringify(filter) }, - }); - tableRows.value = data; - } catch (err) { - console.error('Error fetching travels'); } + + filter.where = where; + const { data } = await axios.get('Travels', { + params: { filter: JSON.stringify(filter) }, + }); + tableRows.value = data; }; const closeForm = () => { diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 05f947cf3..9ac2d38a5 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -217,9 +217,6 @@ async function save() { updateAndEmit('onDataSaved', formData.value, response?.data); if ($props.reload) await arrayData.fetch({}); hasChanges.value = false; - } catch (err) { - console.error(err); - notify('errors.writeRequest', 'negative'); } finally { isLoading.value = false; } diff --git a/src/components/ItemsFilterPanel.vue b/src/components/ItemsFilterPanel.vue index cf91968e2..e20c10edf 100644 --- a/src/components/ItemsFilterPanel.vue +++ b/src/components/ItemsFilterPanel.vue @@ -106,23 +106,19 @@ const getCategoryClass = (category, params) => { }; const getSelectedTagValues = async (tag) => { - try { - if (!tag?.selectedTag?.id) return; - tag.value = null; - const filter = { - fields: ['value'], - order: 'value ASC', - limit: 30, - }; + if (!tag?.selectedTag?.id) return; + tag.value = null; + const filter = { + fields: ['value'], + order: 'value ASC', + limit: 30, + }; - const params = { filter: JSON.stringify(filter) }; - const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, { - params, - }); - tag.valueOptions = data; - } catch (err) { - console.error('Error getting selected tag values'); - } + const params = { filter: JSON.stringify(filter) }; + const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, { + params, + }); + tag.valueOptions = data; }; const removeTag = (index, params, search) => { diff --git a/src/components/RefundInvoiceForm.vue b/src/components/RefundInvoiceForm.vue index 9d9f0cff1..590acede0 100644 --- a/src/components/RefundInvoiceForm.vue +++ b/src/components/RefundInvoiceForm.vue @@ -39,14 +39,10 @@ const refund = async () => { invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk, }; - try { - const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params); - notify(t('Refunded invoice'), 'positive'); - const [id] = data?.refundId || []; - if (id) router.push({ name: 'InvoiceOutSummary', params: { id } }); - } catch (err) { - console.error('Error refunding invoice', err); - } + const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params); + notify(t('Refunded invoice'), 'positive'); + const [id] = data?.refundId || []; + if (id) router.push({ name: 'InvoiceOutSummary', params: { id } }); }; diff --git a/src/components/TransferInvoiceForm.vue b/src/components/TransferInvoiceForm.vue index f7050cdba..aa71070d6 100644 --- a/src/components/TransferInvoiceForm.vue +++ b/src/components/TransferInvoiceForm.vue @@ -49,36 +49,32 @@ const makeInvoice = async () => { makeInvoice: checked.value, }; - try { - if (checked.value && hasToInvoiceByAddress) { - const response = await new Promise((resolve) => { - quasar - .dialog({ - component: VnConfirm, - componentProps: { - title: t('Bill destination client'), - message: t('transferInvoiceInfo'), - }, - }) - .onOk(() => { - resolve(true); - }) - .onCancel(() => { - resolve(false); - }); - }); - if (!response) { - return; - } + if (checked.value && hasToInvoiceByAddress) { + const response = await new Promise((resolve) => { + quasar + .dialog({ + component: VnConfirm, + componentProps: { + title: t('Bill destination client'), + message: t('transferInvoiceInfo'), + }, + }) + .onOk(() => { + resolve(true); + }) + .onCancel(() => { + resolve(false); + }); + }); + if (!response) { + return; } - - const { data } = await axios.post('InvoiceOuts/transfer', params); - notify(t('Transferred invoice'), 'positive'); - const id = data?.[0]; - if (id) router.push({ name: 'InvoiceOutSummary', params: { id } }); - } catch (err) { - console.error('Error transfering invoice', err); } + + const { data } = await axios.post('InvoiceOuts/transfer', params); + notify(t('Transferred invoice'), 'positive'); + const id = data?.[0]; + if (id) router.push({ name: 'InvoiceOutSummary', params: { id } }); }; diff --git a/src/components/common/TableVisibleColumns.vue b/src/components/common/TableVisibleColumns.vue index 9a6c70ef0..ee1e56319 100644 --- a/src/components/common/TableVisibleColumns.vue +++ b/src/components/common/TableVisibleColumns.vue @@ -58,79 +58,71 @@ const getConfig = async (url, filter) => { }; const fetchViewConfigData = async () => { - try { - const userConfigFilter = { - where: { tableCode: $props.tableCode, userFk: user.value.id }, - }; - const userConfig = await getConfig('UserConfigViews', userConfigFilter); + const userConfigFilter = { + where: { tableCode: $props.tableCode, userFk: user.value.id }, + }; + const userConfig = await getConfig('UserConfigViews', userConfigFilter); - if (userConfig) { - initialUserConfigViewData.value = userConfig; - setUserConfigViewData(userConfig.configuration); - return; - } + if (userConfig) { + initialUserConfigViewData.value = userConfig; + setUserConfigViewData(userConfig.configuration); + return; + } - const defaultConfigFilter = { where: { tableCode: $props.tableCode } }; - const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter); + const defaultConfigFilter = { where: { tableCode: $props.tableCode } }; + const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter); - if (defaultConfig) { - // Si el backend devuelve una configuración por defecto la usamos - setUserConfigViewData(defaultConfig.columns); - return; - } else { - // Si no hay configuración por defecto mostramos todas las columnas - const defaultColumns = {}; - $props.allColumns.forEach((col) => (defaultColumns[col] = true)); - setUserConfigViewData(defaultColumns); - } - } catch (err) { - console.error('Error fetching config view data', err); + if (defaultConfig) { + // Si el backend devuelve una configuración por defecto la usamos + setUserConfigViewData(defaultConfig.columns); + return; + } else { + // Si no hay configuración por defecto mostramos todas las columnas + const defaultColumns = {}; + $props.allColumns.forEach((col) => (defaultColumns[col] = true)); + setUserConfigViewData(defaultColumns); } }; const saveConfig = async () => { - try { - const params = {}; - const configuration = {}; + const params = {}; + const configuration = {}; - formattedCols.value.forEach((col) => { - const { name, active } = col; - configuration[name] = active; - }); + formattedCols.value.forEach((col) => { + const { name, active } = col; + configuration[name] = active; + }); - // Si existe una view config del usuario hacemos un update si no la creamos - if (initialUserConfigViewData.value) { - params.updates = [ - { - data: { - configuration: configuration, - }, - where: { - id: initialUserConfigViewData.value.id, - }, - }, - ]; - } else { - params.creates = [ - { - userFk: user.value.id, - tableCode: $props.tableCode, - tableConfig: $props.tableCode, + // Si existe una view config del usuario hacemos un update si no la creamos + if (initialUserConfigViewData.value) { + params.updates = [ + { + data: { configuration: configuration, }, - ]; - } - - const response = await axios.post('UserConfigViews/crud', params); - if (response.data && response.data[0]) { - initialUserConfigViewData.value = response.data[0]; - } - emitSavedConfig(); - notify('globals.dataSaved', 'positive'); - popupProxyRef.value.hide(); - } catch (err) { - console.error('Error saving user view config', err); + where: { + id: initialUserConfigViewData.value.id, + }, + }, + ]; + } else { + params.creates = [ + { + userFk: user.value.id, + tableCode: $props.tableCode, + tableConfig: $props.tableCode, + configuration: configuration, + }, + ]; } + + const response = await axios.post('UserConfigViews/crud', params); + if (response.data && response.data[0]) { + initialUserConfigViewData.value = response.data[0]; + } + emitSavedConfig(); + notify('globals.dataSaved', 'positive'); + popupProxyRef.value.hide(); }; const emitSavedConfig = () => { diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue index 1246eedcd..a74044136 100644 --- a/src/components/common/VnInput.vue +++ b/src/components/common/VnInput.vue @@ -99,7 +99,13 @@ const mixinRules = [ {{ value }} - + diff --git a/src/pages/Customer/Card/CustomerAddress.vue b/src/pages/Customer/Card/CustomerAddress.vue index 166c33e1a..3ae5fbafb 100644 --- a/src/pages/Customer/Card/CustomerAddress.vue +++ b/src/pages/Customer/Card/CustomerAddress.vue @@ -167,7 +167,7 @@ const toCustomerAddressEdit = (addressId) => {
{{ item.street }}
{{ item.postalCode }} - {{ item.city }}, - {{ item.province.name }} + {{ item.province?.name }}
{{ item.phone }} diff --git a/src/pages/Customer/Card/CustomerBalance.vue b/src/pages/Customer/Card/CustomerBalance.vue index f6fc3eed2..712be5e09 100644 --- a/src/pages/Customer/Card/CustomerBalance.vue +++ b/src/pages/Customer/Card/CustomerBalance.vue @@ -256,10 +256,10 @@ const showBalancePdf = ({ id }) => { {{ toCurrency(balances[rowIndex]?.balance) }}