diff --git a/src/components/ui/CatalogItem.vue b/src/components/ui/CatalogItem.vue index 0ae890e37..7806562b2 100644 --- a/src/components/ui/CatalogItem.vue +++ b/src/components/ui/CatalogItem.vue @@ -132,8 +132,7 @@ const card = toRef(props, 'item'); display: flex; flex-direction: column; gap: 4px; - white-space: nowrap; - width: 192px; + p { margin-bottom: 0; } diff --git a/src/pages/Customer/Notifications/CustomerNotifications.vue b/src/pages/Customer/Notifications/CustomerNotifications.vue index cbbd6d205..79b9c9063 100644 --- a/src/pages/Customer/Notifications/CustomerNotifications.vue +++ b/src/pages/Customer/Notifications/CustomerNotifications.vue @@ -26,6 +26,7 @@ const columns = computed(() => [ url: 'Clients', fields: ['id', 'socialName'], optionLabel: 'socialName', + optionValue: 'socialName', }, }, columnClass: 'expand', @@ -37,8 +38,11 @@ const columns = computed(() => [ name: 'city', columnFilter: { component: 'select', + inWhere: true, attrs: { url: 'Towns', + optionValue: 'name', + optionLabel: 'name', }, }, cardVisible: true, @@ -95,7 +99,7 @@ const columns = computed(() => [ { + expect(getItemPackagingType(null)).toBe('-'); + expect(getItemPackagingType(undefined)).toBe('-'); + }); + + it('should return "-" if ticketSales does not have a length property', () => { + const ticketSales = { someKey: 'someValue' }; // No tiene propiedad length + expect(getItemPackagingType(ticketSales)).toBe('-'); + }); + + it('should return unique packaging types as a comma-separated string', () => { + const ticketSales = [ + { item: { itemPackingTypeFk: 'H' } }, + { item: { itemPackingTypeFk: 'V' } }, + { item: { itemPackingTypeFk: 'H' } }, + ]; + expect(getItemPackagingType(ticketSales)).toBe('H, V'); + }); + it('should return unique packaging types as a comma-separated string', () => { + const ticketSales = [ + { item: { itemPackingTypeFk: 'H' } }, + { item: { itemPackingTypeFk: 'V' } }, + { item: { itemPackingTypeFk: 'H' } }, + { item: { itemPackingTypeFk: 'A' } }, + ]; + expect(getItemPackagingType(ticketSales)).toBe('H, V, A'); + }); + + it('should return "-" if ticketSales is an empty array', () => { + expect(getItemPackagingType([])).toBe('-'); + }); +}); diff --git a/src/pages/Customer/composables/getItemPackagingType.js b/src/pages/Customer/composables/getItemPackagingType.js new file mode 100644 index 000000000..eba4d62f5 --- /dev/null +++ b/src/pages/Customer/composables/getItemPackagingType.js @@ -0,0 +1,11 @@ +import { dashIfEmpty } from 'src/filters'; + +export function getItemPackagingType(ticketSales) { + if (!ticketSales?.length) return '-'; + + const packagingTypes = Array.from( + new Set(ticketSales.map(({ item: { itemPackingTypeFk } }) => itemPackingTypeFk)), + ); + + return dashIfEmpty(packagingTypes.join(', ')); +} diff --git a/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue b/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue index f682537f6..13f2a8a94 100644 --- a/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue +++ b/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue @@ -8,7 +8,6 @@ import VnRow from 'components/ui/VnRow.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue'; -import VnInputTime from 'components/common/VnInputTime.vue'; import axios from 'axios'; import useNotify from 'src/composables/useNotify.js'; @@ -59,11 +58,25 @@ const zoneWhere = computed(() => { }); async function getLanded(params) { - getDate(`Agencies/getLanded`, params); + const data = await getDate(`Agencies/getLanded`, params); + formData.value.landed = data.landed; + const shippedDate = new Date(params.shipped); + const landedDate = new Date(data.hour); + shippedDate.setHours( + landedDate.getHours(), + landedDate.getMinutes(), + landedDate.getSeconds(), + ); + formData.value.shipped = shippedDate.toISOString(); } async function getShipped(params) { - getDate(`Agencies/getShipped`, params); + const data = await getDate(`Agencies/getShipped`, params); + formData.value.landed = params.landed; + const [hours, minutes, seconds] = data.hour.split(':').map(Number); + let shippedDate = new Date(data.shipped); + shippedDate.setHours(hours, minutes, seconds); + formData.value.shipped = shippedDate.toISOString(); } async function getDate(query, params) { @@ -75,15 +88,8 @@ async function getDate(query, params) { if (!data) return notify(t('basicData.noDeliveryZoneAvailable'), 'negative'); formData.value.zoneFk = data.zoneFk; - formData.value.landed = data.landed; - const shippedDate = new Date(params.shipped); - const landedDate = new Date(data.hour); - shippedDate.setHours( - landedDate.getHours(), - landedDate.getMinutes(), - landedDate.getSeconds(), - ); - formData.value.shipped = shippedDate.toISOString(); + + return data; } const onChangeZone = async (zoneId) => { @@ -270,8 +276,6 @@ async function getZone(options) {