@open-tender/utils 0.5.64 → 0.5.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/utils/maps.js +16 -2
- package/dist/esm/utils/maps.js +16 -2
- package/package.json +2 -2
package/dist/cjs/utils/maps.js
CHANGED
|
@@ -50,9 +50,23 @@ const addDistance = (revenueCenters, latLng) => {
|
|
|
50
50
|
const iLatLng = i.address.lat
|
|
51
51
|
? { lat: i.address.lat, lng: i.address.lng }
|
|
52
52
|
: null;
|
|
53
|
-
|
|
53
|
+
// Use backend travel_distance (real driving distance) if available,
|
|
54
|
+
// otherwise fall back to client-side Haversine calculation
|
|
55
|
+
if (i.travel_distance !== null && i.travel_distance !== undefined) {
|
|
56
|
+
i.distance = i.travel_distance;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
i.distance = iLatLng ? (0, exports.getDistance)(latLng, iLatLng) : 1000;
|
|
60
|
+
}
|
|
54
61
|
const { coordinates, priority } = i.delivery_zone;
|
|
55
|
-
|
|
62
|
+
// Use backend in_zone if driving distance validation was applied,
|
|
63
|
+
// otherwise fall back to client-side polygon check
|
|
64
|
+
if (i.in_delivery_range !== null && i.in_delivery_range !== undefined) {
|
|
65
|
+
i.inZone = i.in_delivery_range;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
i.inZone = coordinates ? (0, exports.inZone)(latLng, coordinates) : false;
|
|
69
|
+
}
|
|
56
70
|
i.priority = priority !== null && priority !== void 0 ? priority : 0;
|
|
57
71
|
return i;
|
|
58
72
|
});
|
package/dist/esm/utils/maps.js
CHANGED
|
@@ -45,9 +45,23 @@ export const addDistance = (revenueCenters, latLng) => {
|
|
|
45
45
|
const iLatLng = i.address.lat
|
|
46
46
|
? { lat: i.address.lat, lng: i.address.lng }
|
|
47
47
|
: null;
|
|
48
|
-
|
|
48
|
+
// Use backend travel_distance (real driving distance) if available,
|
|
49
|
+
// otherwise fall back to client-side Haversine calculation
|
|
50
|
+
if (i.travel_distance !== null && i.travel_distance !== undefined) {
|
|
51
|
+
i.distance = i.travel_distance;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
i.distance = iLatLng ? getDistance(latLng, iLatLng) : 1000;
|
|
55
|
+
}
|
|
49
56
|
const { coordinates, priority } = i.delivery_zone;
|
|
50
|
-
|
|
57
|
+
// Use backend in_zone if driving distance validation was applied,
|
|
58
|
+
// otherwise fall back to client-side polygon check
|
|
59
|
+
if (i.in_delivery_range !== null && i.in_delivery_range !== undefined) {
|
|
60
|
+
i.inZone = i.in_delivery_range;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
i.inZone = coordinates ? inZone(latLng, coordinates) : false;
|
|
64
|
+
}
|
|
51
65
|
i.priority = priority !== null && priority !== void 0 ? priority : 0;
|
|
52
66
|
return i;
|
|
53
67
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.66",
|
|
4
4
|
"description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typescript": "^4.8.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@open-tender/types": "^0.4.
|
|
60
|
+
"@open-tender/types": "^0.4.175",
|
|
61
61
|
"@reduxjs/toolkit": "^1.8.5",
|
|
62
62
|
"react": "^18.2.0"
|
|
63
63
|
},
|