refactor: use Salix to create or edit an Order #132

Merged
jsegarra merged 16 commits from ldragan/hedera-web:taro/sc into beta 2025-04-16 22:01:49 +00:00
1 changed files with 24 additions and 34 deletions
Showing only changes of commit d67f1f2427 - Show all commits

View File

@ -223,25 +223,30 @@ const getOrder = async (orderId) => {
return data;
};
const getAgenciesInZone = async () => {
const agenciesInZone = await api.get('Agencies/landsThatDay', {
params: {
addressFk: orderForm.value.address,
landed: new Date(orderForm.value.date),
}
});
const deliveryMethods = await api.get('DeliveryMethods');
return agenciesInZone.data
.filter(agency => agency.isVisible)
.map(agency => ({
id: agency.agencyModeFk,
description: agency.description,
deliveryMethod: deliveryMethods.data.find(dm => dm.id === agency.deliveryMethodFk).code,
}))
.toSorted((a, b) => a.description.localeCompare(b.description));
};
const getAgencies = async () => {
try {
const agenciesInZone = await api.get('Agencies/landsThatDay', {
params: {
addressFk: orderForm.value.address,
landed: new Date(orderForm.value.date),
}
});
const deliveryMethods = await api.get('DeliveryMethods');
const results = agenciesInZone.data
.filter(agency => agency.isVisible)
.map(agency => ({
id: agency.agencyModeFk,
description: agency.description,
deliveryMethod: deliveryMethods.data.find(dm => dm.id === agency.deliveryMethodFk).code,
}))
.filter(agency => agency.deliveryMethod === 'AGENCY' || agency.deliveryMethod === 'DELIVERY')
.toSorted((a, b) => a.description.localeCompare(b.description));
const agenciesInZone = await getAgenciesInZone();
const results = agenciesInZone
.filter(agency => agency.deliveryMethod === 'AGENCY' || agency.deliveryMethod === 'DELIVERY');
agencies.value = results;
@ -260,23 +265,8 @@ const getAgencies = async () => {
const getWarehouses = async () => {
try {
const agenciesInZone = await api.get('Agencies/landsThatDay', {
params: {
addressFk: orderForm.value.address,
landed: new Date(orderForm.value.date),
}
});
const deliveryMethods = await api.get('DeliveryMethods');
const results = agenciesInZone.data
.filter(agency => agency.isVisible)
.map(agency => ({
id: agency.agencyModeFk,
description: agency.description,
deliveryMethod: deliveryMethods.data.find(dm => dm.id === agency.deliveryMethodFk).code,
}))
.filter(agency => agency.deliveryMethod === 'PICKUP')
.toSorted((a, b) => a.description.localeCompare(b.description));
const agenciesInZone = await getAgenciesInZone();
const results = agenciesInZone.filter(agency => agency.deliveryMethod === 'PICKUP');
warehouses.value = results;