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 () => {
|
const getWarehouses = 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 ('PICKUP')
|
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,
|
||||||
);
|
}))
|
||||||
warehouses.value = results[1].data;
|
.filter(agency => agency.deliveryMethod === 'PICKUP')
|
||||||
|
.toSorted((a, b) => a.description.localeCompare(b.description));
|
||||||
|
|
||||||
|
warehouses.value = results;
|
||||||
|
|
||||||
if (!warehouses.value || !warehouses.value.length) {
|
if (!warehouses.value || !warehouses.value.length) {
|
||||||
notify(t('noWarehousesAvailableForDate'), 'negative');
|
notify(t('noWarehousesAvailableForDate'), 'negative');
|
||||||
|
|
Loading…
Reference in New Issue