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 () => { const getAgencies = async () => {
try { try {
const { results } = await jApi.execQuery( const agenciesInZone = await api.get('Agencies/landsThatDay', {
`CALL vn.zone_getAgency(#address, #date); params: {
SELECT DISTINCT a.agencyModeFk id, a.description addressFk: orderForm.value.address,
FROM tmp.zoneGetAgency a landed: new Date(orderForm.value.date),
JOIN vn.deliveryMethod d }
ON d.id = a.deliveryMethodFk });
WHERE d.code IN ('AGENCY', 'DELIVERY') const deliveryMethods = await api.get('DeliveryMethods');
AND a.isVisible
ORDER BY a.description; const results = agenciesInZone.data
DROP TEMPORARY TABLE tmp.zoneGetAgency`, .filter(agency => agency.isVisible)
{ .map(agency => ({
address: orderForm.value.address, id: agency.agencyModeFk,
date: new Date(orderForm.value.date) description: agency.description,
} deliveryMethod: deliveryMethods.data.find(dm => dm.id === agency.deliveryMethodFk).code,
); }))
agencies.value = results[1].data; .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) { if (agencies.value && agencies.value.length && defaultValues.value) {
const found = agencies.value.find( const found = agencies.value.find(