refactor(CheckoutView): use salix for getAgencies
gitea/hedera-web/pipeline/pr-beta This commit looks good Details

This commit is contained in:
taro 2025-03-31 03:35:52 -03:00
parent 9e39809967
commit e7f4ece0a7
1 changed files with 19 additions and 16 deletions

View File

@ -198,22 +198,25 @@ const getAddresses = async (clientFk) => {
const getAgencies = async () => {
try {
const { results } = await jApi.execQuery(
`CALL vn.zone_getAgency(#address, #date);
SELECT DISTINCT a.agencyModeFk id, a.description
FROM tmp.zoneGetAgency a
JOIN vn.deliveryMethod d
ON d.id = a.deliveryMethodFk
WHERE d.code IN ('AGENCY', 'DELIVERY')
AND a.isVisible
ORDER BY a.description;
DROP TEMPORARY TABLE tmp.zoneGetAgency`,
{
address: orderForm.value.address,
date: new Date(orderForm.value.date)
}
);
agencies.value = results[1].data;
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));
agencies.value = results;
if (agencies.value && agencies.value.length && defaultValues.value) {
const found = agencies.value.find(