diff --git a/src/pages/Customer/composables/__tests__/getAddresses.spec.js b/src/pages/Customer/composables/__tests__/getAddresses.spec.js index 9e04a83cc..8c90bf281 100644 --- a/src/pages/Customer/composables/__tests__/getAddresses.spec.js +++ b/src/pages/Customer/composables/__tests__/getAddresses.spec.js @@ -17,9 +17,9 @@ describe('getAddresses', () => { expect(axios.get).toHaveBeenCalledWith(`Clients/${clientId}/addresses`, { params: { filter: JSON.stringify({ - fields: ['nickname', 'street', 'city', 'id'], + fields: ['nickname', 'street', 'city', 'id', 'isActive'], where: { isActive: true }, - order: 'nickname ASC', + order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'], }), }, }); @@ -30,4 +30,4 @@ describe('getAddresses', () => { expect(axios.get).not.toHaveBeenCalled(); }); -}); \ No newline at end of file +}); diff --git a/src/pages/Customer/composables/getAddresses.js b/src/pages/Customer/composables/getAddresses.js index e65e64455..5f18530e7 100644 --- a/src/pages/Customer/composables/getAddresses.js +++ b/src/pages/Customer/composables/getAddresses.js @@ -1,15 +1,15 @@ import axios from 'axios'; -export async function getAddresses(clientId, _filter = {}) { +export async function getAddresses(clientId, _filter = {}) { if (!clientId) return; const filter = { ..._filter, - fields: ['nickname', 'street', 'city', 'id'], + fields: ['nickname', 'street', 'city', 'id', 'isActive'], where: { isActive: true }, - order: 'nickname ASC', + order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'], }; const params = { filter: JSON.stringify(filter) }; return await axios.get(`Clients/${clientId}/addresses`, { params, }); -}; \ No newline at end of file +} diff --git a/src/pages/Order/OrderList.vue b/src/pages/Order/OrderList.vue index 40990f329..59ec37f98 100644 --- a/src/pages/Order/OrderList.vue +++ b/src/pages/Order/OrderList.vue @@ -155,11 +155,23 @@ onMounted(() => { }); async function fetchClientAddress(id, formData = {}) { - const { data } = await axios.get( - `Clients/${id}/addresses?filter[order]=isActive DESC` - ); + const { data } = await axios.get(`Clients/${id}/addresses`, { + params: { + filter: JSON.stringify({ + include: [ + { + relation: 'client', + scope: { + fields: ['defaultAddressFk'], + }, + }, + ], + order: ['isActive DESC'], + }), + }, + }); addressOptions.value = data; - formData.addressId = data.defaultAddressFk; + formData.addressId = data[0].client.defaultAddressFk; fetchAgencies(formData); } @@ -167,7 +179,13 @@ async function fetchAgencies({ landed, addressId }) { if (!landed || !addressId) return (agencyList.value = []); const { data } = await axios.get('Agencies/landsThatDay', { - params: { addressFk: addressId, landed }, + params: { + filter: JSON.stringify({ + order: ['agencyMode DESC', 'agencyModeFk ASC'], + }), + addressFk: addressId, + landed, + }, }); agencyList.value = data; } @@ -258,6 +276,7 @@ const getDateColor = (date) => { { {{ scope.opt?.street }}, {{ scope.opt?.city }} + + {{ `#${scope.opt?.id}` }} + diff --git a/src/pages/Route/Agency/composables/__tests__/getAgencies.spec.js b/src/pages/Route/Agency/composables/__tests__/getAgencies.spec.js index ccf7872cb..99966569c 100644 --- a/src/pages/Route/Agency/composables/__tests__/getAgencies.spec.js +++ b/src/pages/Route/Agency/composables/__tests__/getAgencies.spec.js @@ -27,14 +27,17 @@ describe('getAgencies', () => { landed: 'true', }; const filter = { - fields: ['nickname', 'street', 'city', 'id'], + fields: ['name', 'street', 'city', 'id'], where: { isActive: true }, - order: 'nickname ASC', + order: ['name ASC'], }; await getAgencies(formData, null, filter); - expect(axios.get).toHaveBeenCalledWith('Agencies/getAgenciesWithWarehouse', generateParams(formData, filter)); + expect(axios.get).toHaveBeenCalledWith( + 'Agencies/getAgenciesWithWarehouse', + generateParams(formData, filter), + ); }); it('should not call API when formData is missing required landed field', async () => { @@ -64,19 +67,19 @@ describe('getAgencies', () => { it('should return options and agency when default agency is found', async () => { const formData = { warehouseId: '123', addressId: '456', landed: 'true' }; const client = { defaultAddress: { agencyModeFk: 'Agency1' } }; - + const { options, agency } = await getAgencies(formData, client); - + expect(options).toEqual(response.data); expect(agency).toEqual(response.data[0]); - }); + }); - it('should return options and agency when client is not provided', async () => { + it('should return options and agency when client is not provided', async () => { const formData = { warehouseId: '123', addressId: '456', landed: 'true' }; - + const { options, agency } = await getAgencies(formData); - + expect(options).toEqual(response.data); expect(agency).toBeNull(); - }); + }); }); diff --git a/src/pages/Route/Agency/composables/getAgencies.js b/src/pages/Route/Agency/composables/getAgencies.js index 850f87456..180ac943e 100644 --- a/src/pages/Route/Agency/composables/getAgencies.js +++ b/src/pages/Route/Agency/composables/getAgencies.js @@ -1,14 +1,14 @@ import axios from 'axios'; -import agency from 'src/router/modules/agency'; export async function getAgencies(formData, client, _filter = {}) { if (!formData.warehouseId || !formData.addressId || !formData.landed) return; - + const filter = { - ..._filter + ..._filter, + order: ['name ASC'], }; - let defaultAgency = null; + let agency = null; let params = { filter: JSON.stringify(filter), warehouseFk: formData.warehouseId, @@ -16,11 +16,15 @@ export async function getAgencies(formData, client, _filter = {}) { landed: formData.landed, }; - const { data } = await axios.get('Agencies/getAgenciesWithWarehouse', { params }); + const { data: options } = await axios.get('Agencies/getAgenciesWithWarehouse', { + params, + }); - if(data && client) { - defaultAgency = data.find((agency) => agency.agencyModeFk === client.defaultAddress.agencyModeFk ); - }; - - return {options: data, agency: defaultAgency} + if (options && client) { + agency = options.find( + ({ agencyModeFk }) => agencyModeFk === client.defaultAddress.agencyModeFk, + ); + } + + return { options, agency }; } diff --git a/src/pages/Ticket/Card/TicketExpedition.vue b/src/pages/Ticket/Card/TicketExpedition.vue index f8084ff2f..a41d492ed 100644 --- a/src/pages/Ticket/Card/TicketExpedition.vue +++ b/src/pages/Ticket/Card/TicketExpedition.vue @@ -105,6 +105,9 @@ const columns = computed(() => [ name: 'created', align: 'left', cardVisible: true, + columnFilter: { + component: 'date', + }, format: (row) => toDateTimeFormat(row.created), }, { @@ -201,7 +204,7 @@ const getExpeditionState = async (expedition) => { const openGrafana = (expeditionFk) => { useOpenURL( - `https://grafana.verdnatura.es/d/de1njb6p5answd/control-de-expediciones?orgId=1&var-expeditionFk=${expeditionFk}` + `https://grafana.verdnatura.es/d/de1njb6p5answd/control-de-expediciones?orgId=1&var-expeditionFk=${expeditionFk}`, ); }; @@ -287,7 +290,7 @@ onMounted(async () => { openConfirmationModal( '', t('expedition.removeExpeditionSubtitle'), - deleteExpedition + deleteExpedition, ) " > @@ -302,7 +305,6 @@ onMounted(async () => { url="Expeditions/filter" search-url="expeditions" :columns="columns" - :filter="expeditionsFilter" v-model:selected="selectedRows" :table="{ 'row-key': 'id', @@ -316,6 +318,8 @@ onMounted(async () => { return { id: value }; case 'packageItemName': return { packagingItemFk: value }; + case 'created': + return { 'e.created': { gte: value } }; } } " diff --git a/src/pages/Ticket/Card/TicketTransferProxy.vue b/src/pages/Ticket/Card/TicketTransferProxy.vue index 3f3f018df..7d5d82f85 100644 --- a/src/pages/Ticket/Card/TicketTransferProxy.vue +++ b/src/pages/Ticket/Card/TicketTransferProxy.vue @@ -42,7 +42,7 @@ const transferRef = ref(null); /> -
+
(stateStore.rightDrawer = true));