refactor(CheckoutView): use Salix for getWarehouses
This commit is contained in:
parent
23d97a5f63
commit
bddfb74bd8
|
@ -260,22 +260,25 @@ const getAgencies = async () => {
|
|||
|
||||
const getWarehouses = 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 ('PICKUP')
|
||||
AND a.isVisible
|
||||
ORDER BY a.description;
|
||||
DROP TEMPORARY TABLE tmp.zoneGetAgency;`,
|
||||
{
|
||||
address: orderForm.value.address,
|
||||
date: new Date(orderForm.value.date)
|
||||
}
|
||||
);
|
||||
warehouses.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 === 'PICKUP')
|
||||
.toSorted((a, b) => a.description.localeCompare(b.description));
|
||||
|
||||
warehouses.value = results;
|
||||
|
||||
if (!warehouses.value || !warehouses.value.length) {
|
||||
notify(t('noWarehousesAvailableForDate'), 'negative');
|
||||
|
|
Loading…
Reference in New Issue