refactor(CheckoutView): use salix for getAgencies
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
This commit is contained in:
parent
9e39809967
commit
e7f4ece0a7
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue