@open-tender/utils 0.1.96 → 0.1.98
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/.DS_Store +0 -0
- package/dist/cjs/utils/constants.d.ts +1 -1
- package/dist/cjs/utils/constants.js +1 -1
- package/dist/cjs/utils/maps.d.ts +11 -15
- package/dist/cjs/utils/maps.js +22 -25
- package/dist/esm/utils/constants.d.ts +1 -1
- package/dist/esm/utils/constants.js +1 -1
- package/dist/esm/utils/maps.d.ts +11 -15
- package/dist/esm/utils/maps.js +22 -25
- package/package.json +2 -2
package/dist/.DS_Store
ADDED
|
Binary file
|
package/dist/cjs/utils/maps.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { Address, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
|
|
2
|
-
export interface Point {
|
|
3
|
-
lat: number;
|
|
4
|
-
lng: number;
|
|
5
|
-
}
|
|
1
|
+
import { Address, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
|
|
6
2
|
export interface GooglePlaceAddressComponent {
|
|
7
3
|
types: Array<string | 'postal_code' | 'street_number' | 'route' | 'locality' | 'sublocality_level_1' | 'administrative_area_level_1'>;
|
|
8
4
|
long_name?: string;
|
|
@@ -14,8 +10,8 @@ export declare enum GooglePlaceBusinessStatus {
|
|
|
14
10
|
CLOSED_PERMANENTLY = "CLOSED_PERMANENTLY"
|
|
15
11
|
}
|
|
16
12
|
export interface GooglePlaceAdressGeometry {
|
|
17
|
-
location:
|
|
18
|
-
viewport: Record<string,
|
|
13
|
+
location: LatLng;
|
|
14
|
+
viewport: Record<string, LatLng>;
|
|
19
15
|
}
|
|
20
16
|
export interface GooglePlace {
|
|
21
17
|
address_components: Array<GooglePlaceAddressComponent>;
|
|
@@ -48,16 +44,16 @@ export declare const makeAddress: (place: GooglePlace) => {
|
|
|
48
44
|
lng: number | null;
|
|
49
45
|
formatted_address: string;
|
|
50
46
|
};
|
|
51
|
-
export declare const getDistance: (pointA:
|
|
52
|
-
export declare const inZone: (
|
|
53
|
-
export declare const addDistance: (revenueCenters: RevenueCenters,
|
|
47
|
+
export declare const getDistance: (pointA: LatLng, pointB: LatLng, inMiles?: boolean) => number;
|
|
48
|
+
export declare const inZone: (latLng: LatLng, polygon: number[][]) => boolean;
|
|
49
|
+
export declare const addDistance: (revenueCenters: RevenueCenters, latLng: LatLng) => RevenueCenters;
|
|
54
50
|
export declare const sortRevenueCenters: (revenueCenters: RevenueCenters, isDelivery?: boolean) => RevenueCenter[];
|
|
55
51
|
export declare const calcMinDistance: (revenueCenters: RevenueCenters, maxDistance?: number) => number;
|
|
56
52
|
export declare const checkServiceType: (revenueCenter: RevenueCenter, serviceType: ServiceType) => boolean;
|
|
57
53
|
export declare const makePickupRevenueCenters: (revenueCenters: Array<RevenueCenter>, maxDistance?: number) => RevenueCenter[];
|
|
58
54
|
export declare const makeWalkinRevenueCenters: (revenueCenters: Array<RevenueCenter>, maxDistance?: number) => RevenueCenter[];
|
|
59
55
|
export declare const makeDeliveryRevenueCenters: (revenueCenters: Array<RevenueCenter>) => RevenueCenter[];
|
|
60
|
-
export declare const makePickupMesssaging: (address: Address,
|
|
56
|
+
export declare const makePickupMesssaging: (address: Address | null, latLng: LatLng | null, count: number, minDistance: number, maxDistance?: number, messages?: {
|
|
61
57
|
PICKUP: {
|
|
62
58
|
default: {
|
|
63
59
|
title: string;
|
|
@@ -106,7 +102,7 @@ export declare const makePickupMesssaging: (address: Address, geoLatLng: any, co
|
|
|
106
102
|
title: string;
|
|
107
103
|
msg: string;
|
|
108
104
|
};
|
|
109
|
-
export declare const makeWalkinMessaging: (address: Address,
|
|
105
|
+
export declare const makeWalkinMessaging: (address: Address | null, latLng: LatLng | null, count: number, minDistance: number, maxDistance?: number, messages?: {
|
|
110
106
|
PICKUP: {
|
|
111
107
|
default: {
|
|
112
108
|
title: string;
|
|
@@ -155,7 +151,7 @@ export declare const makeWalkinMessaging: (address: Address, geoLatLng: any, cou
|
|
|
155
151
|
title: string;
|
|
156
152
|
msg: string;
|
|
157
153
|
};
|
|
158
|
-
export declare const makeDeliveryMesssaging: (address: Address, count: number, messages?: {
|
|
154
|
+
export declare const makeDeliveryMesssaging: (address: Address | null, count: number, messages?: {
|
|
159
155
|
PICKUP: {
|
|
160
156
|
default: {
|
|
161
157
|
title: string;
|
|
@@ -209,7 +205,7 @@ export declare const makeDeliveryMesssaging: (address: Address, count: number, m
|
|
|
209
205
|
msg: string;
|
|
210
206
|
error: string;
|
|
211
207
|
};
|
|
212
|
-
export declare const makeDisplayedRevenueCenters: (revenueCenters:
|
|
208
|
+
export declare const makeDisplayedRevenueCenters: (revenueCenters: RevenueCenter[], serviceType: ServiceType | null, address: Address | null, latLng: LatLng | null, maxDistance: number, isGroupOrder: boolean) => {
|
|
213
209
|
title: string;
|
|
214
210
|
msg: string;
|
|
215
211
|
error: string | null;
|
|
@@ -261,4 +257,4 @@ export declare const LOCATIONS_MESSAGES: {
|
|
|
261
257
|
};
|
|
262
258
|
};
|
|
263
259
|
};
|
|
264
|
-
export declare const renameLocation: (str:
|
|
260
|
+
export declare const renameLocation: (str: string, names: string[]) => string;
|
package/dist/cjs/utils/maps.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renameLocation = exports.LOCATIONS_MESSAGES = exports.makeDisplayedRevenueCenters = exports.makeDeliveryMesssaging = exports.makeWalkinMessaging = exports.makePickupMesssaging = exports.makeDeliveryRevenueCenters = exports.makeWalkinRevenueCenters = exports.makePickupRevenueCenters = exports.checkServiceType = exports.calcMinDistance = exports.sortRevenueCenters = exports.addDistance = exports.inZone = exports.getDistance = exports.makeAddress = exports.GooglePlaceBusinessStatus = void 0;
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
|
-
const helpers_1 = require("./helpers");
|
|
6
5
|
var GooglePlaceBusinessStatus;
|
|
7
6
|
(function (GooglePlaceBusinessStatus) {
|
|
8
7
|
GooglePlaceBusinessStatus["OPERATIONAL"] = "OPERATIONAL";
|
|
@@ -69,21 +68,21 @@ const pointInPolygon = (point, vs) => {
|
|
|
69
68
|
}
|
|
70
69
|
return inside;
|
|
71
70
|
};
|
|
72
|
-
const inZone = (
|
|
73
|
-
const point = [
|
|
71
|
+
const inZone = (latLng, polygon) => {
|
|
72
|
+
const point = [latLng.lat, latLng.lng];
|
|
74
73
|
return pointInPolygon(point, polygon);
|
|
75
74
|
};
|
|
76
75
|
exports.inZone = inZone;
|
|
77
|
-
const addDistance = (revenueCenters,
|
|
78
|
-
if (!
|
|
76
|
+
const addDistance = (revenueCenters, latLng) => {
|
|
77
|
+
if (!latLng)
|
|
79
78
|
return revenueCenters;
|
|
80
79
|
const withDistance = revenueCenters.map(i => {
|
|
81
|
-
const
|
|
80
|
+
const iLatLng = i.address.lat
|
|
82
81
|
? { lat: i.address.lat, lng: i.address.lng }
|
|
83
82
|
: null;
|
|
84
|
-
i.distance =
|
|
83
|
+
i.distance = iLatLng ? (0, exports.getDistance)(latLng, iLatLng) : 1000;
|
|
85
84
|
const { coordinates, priority } = i.delivery_zone;
|
|
86
|
-
i.inZone = coordinates ? (0, exports.inZone)(
|
|
85
|
+
i.inZone = coordinates ? (0, exports.inZone)(latLng, coordinates) : false;
|
|
87
86
|
i.priority = priority !== null && priority !== void 0 ? priority : 0;
|
|
88
87
|
return i;
|
|
89
88
|
});
|
|
@@ -140,7 +139,7 @@ const makeDeliveryRevenueCenters = (revenueCenters) => {
|
|
|
140
139
|
return sorted.filter(i => i.inZone);
|
|
141
140
|
};
|
|
142
141
|
exports.makeDeliveryRevenueCenters = makeDeliveryRevenueCenters;
|
|
143
|
-
const makePickupMesssaging = (address,
|
|
142
|
+
const makePickupMesssaging = (address, latLng, count, minDistance, maxDistance = constants_1.MAX_DISTANCE, messages = exports.LOCATIONS_MESSAGES) => {
|
|
144
143
|
if (address) {
|
|
145
144
|
if (minDistance >= maxDistance) {
|
|
146
145
|
return messages.PICKUP.addressFar;
|
|
@@ -152,7 +151,7 @@ const makePickupMesssaging = (address, geoLatLng, count, minDistance, maxDistanc
|
|
|
152
151
|
};
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
|
-
else if (
|
|
154
|
+
else if (latLng) {
|
|
156
155
|
if (minDistance >= maxDistance) {
|
|
157
156
|
return messages.PICKUP.geoFar;
|
|
158
157
|
}
|
|
@@ -168,8 +167,8 @@ const makePickupMesssaging = (address, geoLatLng, count, minDistance, maxDistanc
|
|
|
168
167
|
}
|
|
169
168
|
};
|
|
170
169
|
exports.makePickupMesssaging = makePickupMesssaging;
|
|
171
|
-
const makeWalkinMessaging = (address,
|
|
172
|
-
const { title, msg } = (0, exports.makePickupMesssaging)(address,
|
|
170
|
+
const makeWalkinMessaging = (address, latLng, count, minDistance, maxDistance = constants_1.MAX_DISTANCE, messages = exports.LOCATIONS_MESSAGES) => {
|
|
171
|
+
const { title, msg } = (0, exports.makePickupMesssaging)(address, latLng, count, minDistance, maxDistance, messages);
|
|
173
172
|
return {
|
|
174
173
|
title: title.replace('pickup', 'dine-in'),
|
|
175
174
|
msg: msg.replace('pickup', 'dine-in')
|
|
@@ -198,30 +197,30 @@ const makeDeliveryMesssaging = (address, count, messages = exports.LOCATIONS_MES
|
|
|
198
197
|
}
|
|
199
198
|
};
|
|
200
199
|
exports.makeDeliveryMesssaging = makeDeliveryMesssaging;
|
|
201
|
-
const makeDisplayedRevenueCenters = (revenueCenters, serviceType, address,
|
|
200
|
+
const makeDisplayedRevenueCenters = (revenueCenters, serviceType, address, latLng, maxDistance, isGroupOrder) => {
|
|
202
201
|
const filtered = isGroupOrder
|
|
203
202
|
? revenueCenters.filter(i => i.group_ordering)
|
|
204
203
|
: revenueCenters;
|
|
205
|
-
if (serviceType === '
|
|
206
|
-
const displayed = (0, exports.
|
|
207
|
-
const minDistance = (0, exports.calcMinDistance)(displayed);
|
|
204
|
+
if (serviceType === 'DELIVERY') {
|
|
205
|
+
const displayed = (0, exports.makeDeliveryRevenueCenters)(filtered);
|
|
208
206
|
const count = displayed.length;
|
|
209
|
-
const { title, msg } = (0, exports.
|
|
210
|
-
const error = null;
|
|
207
|
+
const { title, msg, error } = (0, exports.makeDeliveryMesssaging)(address, count);
|
|
211
208
|
return { title, msg, error, displayed };
|
|
212
209
|
}
|
|
213
|
-
else if (serviceType === '
|
|
214
|
-
const displayed = (0, exports.
|
|
210
|
+
else if (serviceType === 'WALKIN') {
|
|
211
|
+
const displayed = (0, exports.makeWalkinRevenueCenters)(filtered, maxDistance);
|
|
215
212
|
const minDistance = (0, exports.calcMinDistance)(displayed);
|
|
216
213
|
const count = displayed.length;
|
|
217
|
-
const { title, msg } = (0, exports.
|
|
214
|
+
const { title, msg } = (0, exports.makeWalkinMessaging)(address, latLng, count, minDistance, maxDistance);
|
|
218
215
|
const error = null;
|
|
219
216
|
return { title, msg, error, displayed };
|
|
220
217
|
}
|
|
221
218
|
else {
|
|
222
|
-
const displayed = (0, exports.
|
|
219
|
+
const displayed = (0, exports.makePickupRevenueCenters)(filtered, maxDistance);
|
|
220
|
+
const minDistance = (0, exports.calcMinDistance)(displayed);
|
|
223
221
|
const count = displayed.length;
|
|
224
|
-
const { title, msg
|
|
222
|
+
const { title, msg } = (0, exports.makePickupMesssaging)(address, latLng, count, minDistance, maxDistance);
|
|
223
|
+
const error = null;
|
|
225
224
|
return { title, msg, error, displayed };
|
|
226
225
|
}
|
|
227
226
|
};
|
|
@@ -273,8 +272,6 @@ exports.LOCATIONS_MESSAGES = {
|
|
|
273
272
|
}
|
|
274
273
|
};
|
|
275
274
|
const renameLocation = (str, names) => {
|
|
276
|
-
if (!(0, helpers_1.isString)(str))
|
|
277
|
-
return str;
|
|
278
275
|
const [singular, plural] = names;
|
|
279
276
|
return str
|
|
280
277
|
.replace('1 locations', '1 location')
|
package/dist/esm/utils/maps.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { Address, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
|
|
2
|
-
export interface Point {
|
|
3
|
-
lat: number;
|
|
4
|
-
lng: number;
|
|
5
|
-
}
|
|
1
|
+
import { Address, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
|
|
6
2
|
export interface GooglePlaceAddressComponent {
|
|
7
3
|
types: Array<string | 'postal_code' | 'street_number' | 'route' | 'locality' | 'sublocality_level_1' | 'administrative_area_level_1'>;
|
|
8
4
|
long_name?: string;
|
|
@@ -14,8 +10,8 @@ export declare enum GooglePlaceBusinessStatus {
|
|
|
14
10
|
CLOSED_PERMANENTLY = "CLOSED_PERMANENTLY"
|
|
15
11
|
}
|
|
16
12
|
export interface GooglePlaceAdressGeometry {
|
|
17
|
-
location:
|
|
18
|
-
viewport: Record<string,
|
|
13
|
+
location: LatLng;
|
|
14
|
+
viewport: Record<string, LatLng>;
|
|
19
15
|
}
|
|
20
16
|
export interface GooglePlace {
|
|
21
17
|
address_components: Array<GooglePlaceAddressComponent>;
|
|
@@ -48,16 +44,16 @@ export declare const makeAddress: (place: GooglePlace) => {
|
|
|
48
44
|
lng: number | null;
|
|
49
45
|
formatted_address: string;
|
|
50
46
|
};
|
|
51
|
-
export declare const getDistance: (pointA:
|
|
52
|
-
export declare const inZone: (
|
|
53
|
-
export declare const addDistance: (revenueCenters: RevenueCenters,
|
|
47
|
+
export declare const getDistance: (pointA: LatLng, pointB: LatLng, inMiles?: boolean) => number;
|
|
48
|
+
export declare const inZone: (latLng: LatLng, polygon: number[][]) => boolean;
|
|
49
|
+
export declare const addDistance: (revenueCenters: RevenueCenters, latLng: LatLng) => RevenueCenters;
|
|
54
50
|
export declare const sortRevenueCenters: (revenueCenters: RevenueCenters, isDelivery?: boolean) => RevenueCenter[];
|
|
55
51
|
export declare const calcMinDistance: (revenueCenters: RevenueCenters, maxDistance?: number) => number;
|
|
56
52
|
export declare const checkServiceType: (revenueCenter: RevenueCenter, serviceType: ServiceType) => boolean;
|
|
57
53
|
export declare const makePickupRevenueCenters: (revenueCenters: Array<RevenueCenter>, maxDistance?: number) => RevenueCenter[];
|
|
58
54
|
export declare const makeWalkinRevenueCenters: (revenueCenters: Array<RevenueCenter>, maxDistance?: number) => RevenueCenter[];
|
|
59
55
|
export declare const makeDeliveryRevenueCenters: (revenueCenters: Array<RevenueCenter>) => RevenueCenter[];
|
|
60
|
-
export declare const makePickupMesssaging: (address: Address,
|
|
56
|
+
export declare const makePickupMesssaging: (address: Address | null, latLng: LatLng | null, count: number, minDistance: number, maxDistance?: number, messages?: {
|
|
61
57
|
PICKUP: {
|
|
62
58
|
default: {
|
|
63
59
|
title: string;
|
|
@@ -106,7 +102,7 @@ export declare const makePickupMesssaging: (address: Address, geoLatLng: any, co
|
|
|
106
102
|
title: string;
|
|
107
103
|
msg: string;
|
|
108
104
|
};
|
|
109
|
-
export declare const makeWalkinMessaging: (address: Address,
|
|
105
|
+
export declare const makeWalkinMessaging: (address: Address | null, latLng: LatLng | null, count: number, minDistance: number, maxDistance?: number, messages?: {
|
|
110
106
|
PICKUP: {
|
|
111
107
|
default: {
|
|
112
108
|
title: string;
|
|
@@ -155,7 +151,7 @@ export declare const makeWalkinMessaging: (address: Address, geoLatLng: any, cou
|
|
|
155
151
|
title: string;
|
|
156
152
|
msg: string;
|
|
157
153
|
};
|
|
158
|
-
export declare const makeDeliveryMesssaging: (address: Address, count: number, messages?: {
|
|
154
|
+
export declare const makeDeliveryMesssaging: (address: Address | null, count: number, messages?: {
|
|
159
155
|
PICKUP: {
|
|
160
156
|
default: {
|
|
161
157
|
title: string;
|
|
@@ -209,7 +205,7 @@ export declare const makeDeliveryMesssaging: (address: Address, count: number, m
|
|
|
209
205
|
msg: string;
|
|
210
206
|
error: string;
|
|
211
207
|
};
|
|
212
|
-
export declare const makeDisplayedRevenueCenters: (revenueCenters:
|
|
208
|
+
export declare const makeDisplayedRevenueCenters: (revenueCenters: RevenueCenter[], serviceType: ServiceType | null, address: Address | null, latLng: LatLng | null, maxDistance: number, isGroupOrder: boolean) => {
|
|
213
209
|
title: string;
|
|
214
210
|
msg: string;
|
|
215
211
|
error: string | null;
|
|
@@ -261,4 +257,4 @@ export declare const LOCATIONS_MESSAGES: {
|
|
|
261
257
|
};
|
|
262
258
|
};
|
|
263
259
|
};
|
|
264
|
-
export declare const renameLocation: (str:
|
|
260
|
+
export declare const renameLocation: (str: string, names: string[]) => string;
|
package/dist/esm/utils/maps.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MAX_DISTANCE } from './constants';
|
|
2
|
-
import { isString } from './helpers';
|
|
3
2
|
export var GooglePlaceBusinessStatus;
|
|
4
3
|
(function (GooglePlaceBusinessStatus) {
|
|
5
4
|
GooglePlaceBusinessStatus["OPERATIONAL"] = "OPERATIONAL";
|
|
@@ -64,20 +63,20 @@ const pointInPolygon = (point, vs) => {
|
|
|
64
63
|
}
|
|
65
64
|
return inside;
|
|
66
65
|
};
|
|
67
|
-
export const inZone = (
|
|
68
|
-
const point = [
|
|
66
|
+
export const inZone = (latLng, polygon) => {
|
|
67
|
+
const point = [latLng.lat, latLng.lng];
|
|
69
68
|
return pointInPolygon(point, polygon);
|
|
70
69
|
};
|
|
71
|
-
export const addDistance = (revenueCenters,
|
|
72
|
-
if (!
|
|
70
|
+
export const addDistance = (revenueCenters, latLng) => {
|
|
71
|
+
if (!latLng)
|
|
73
72
|
return revenueCenters;
|
|
74
73
|
const withDistance = revenueCenters.map(i => {
|
|
75
|
-
const
|
|
74
|
+
const iLatLng = i.address.lat
|
|
76
75
|
? { lat: i.address.lat, lng: i.address.lng }
|
|
77
76
|
: null;
|
|
78
|
-
i.distance =
|
|
77
|
+
i.distance = iLatLng ? getDistance(latLng, iLatLng) : 1000;
|
|
79
78
|
const { coordinates, priority } = i.delivery_zone;
|
|
80
|
-
i.inZone = coordinates ? inZone(
|
|
79
|
+
i.inZone = coordinates ? inZone(latLng, coordinates) : false;
|
|
81
80
|
i.priority = priority !== null && priority !== void 0 ? priority : 0;
|
|
82
81
|
return i;
|
|
83
82
|
});
|
|
@@ -127,7 +126,7 @@ export const makeDeliveryRevenueCenters = (revenueCenters) => {
|
|
|
127
126
|
const sorted = sortRevenueCenters(hasDelivery, true);
|
|
128
127
|
return sorted.filter(i => i.inZone);
|
|
129
128
|
};
|
|
130
|
-
export const makePickupMesssaging = (address,
|
|
129
|
+
export const makePickupMesssaging = (address, latLng, count, minDistance, maxDistance = MAX_DISTANCE, messages = LOCATIONS_MESSAGES) => {
|
|
131
130
|
if (address) {
|
|
132
131
|
if (minDistance >= maxDistance) {
|
|
133
132
|
return messages.PICKUP.addressFar;
|
|
@@ -139,7 +138,7 @@ export const makePickupMesssaging = (address, geoLatLng, count, minDistance, max
|
|
|
139
138
|
};
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
|
-
else if (
|
|
141
|
+
else if (latLng) {
|
|
143
142
|
if (minDistance >= maxDistance) {
|
|
144
143
|
return messages.PICKUP.geoFar;
|
|
145
144
|
}
|
|
@@ -154,8 +153,8 @@ export const makePickupMesssaging = (address, geoLatLng, count, minDistance, max
|
|
|
154
153
|
return messages.PICKUP.default;
|
|
155
154
|
}
|
|
156
155
|
};
|
|
157
|
-
export const makeWalkinMessaging = (address,
|
|
158
|
-
const { title, msg } = makePickupMesssaging(address,
|
|
156
|
+
export const makeWalkinMessaging = (address, latLng, count, minDistance, maxDistance = MAX_DISTANCE, messages = LOCATIONS_MESSAGES) => {
|
|
157
|
+
const { title, msg } = makePickupMesssaging(address, latLng, count, minDistance, maxDistance, messages);
|
|
159
158
|
return {
|
|
160
159
|
title: title.replace('pickup', 'dine-in'),
|
|
161
160
|
msg: msg.replace('pickup', 'dine-in')
|
|
@@ -182,30 +181,30 @@ export const makeDeliveryMesssaging = (address, count, messages = LOCATIONS_MESS
|
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
};
|
|
185
|
-
export const makeDisplayedRevenueCenters = (revenueCenters, serviceType, address,
|
|
184
|
+
export const makeDisplayedRevenueCenters = (revenueCenters, serviceType, address, latLng, maxDistance, isGroupOrder) => {
|
|
186
185
|
const filtered = isGroupOrder
|
|
187
186
|
? revenueCenters.filter(i => i.group_ordering)
|
|
188
187
|
: revenueCenters;
|
|
189
|
-
if (serviceType === '
|
|
190
|
-
const displayed =
|
|
191
|
-
const minDistance = calcMinDistance(displayed);
|
|
188
|
+
if (serviceType === 'DELIVERY') {
|
|
189
|
+
const displayed = makeDeliveryRevenueCenters(filtered);
|
|
192
190
|
const count = displayed.length;
|
|
193
|
-
const { title, msg } =
|
|
194
|
-
const error = null;
|
|
191
|
+
const { title, msg, error } = makeDeliveryMesssaging(address, count);
|
|
195
192
|
return { title, msg, error, displayed };
|
|
196
193
|
}
|
|
197
|
-
else if (serviceType === '
|
|
198
|
-
const displayed =
|
|
194
|
+
else if (serviceType === 'WALKIN') {
|
|
195
|
+
const displayed = makeWalkinRevenueCenters(filtered, maxDistance);
|
|
199
196
|
const minDistance = calcMinDistance(displayed);
|
|
200
197
|
const count = displayed.length;
|
|
201
|
-
const { title, msg } =
|
|
198
|
+
const { title, msg } = makeWalkinMessaging(address, latLng, count, minDistance, maxDistance);
|
|
202
199
|
const error = null;
|
|
203
200
|
return { title, msg, error, displayed };
|
|
204
201
|
}
|
|
205
202
|
else {
|
|
206
|
-
const displayed =
|
|
203
|
+
const displayed = makePickupRevenueCenters(filtered, maxDistance);
|
|
204
|
+
const minDistance = calcMinDistance(displayed);
|
|
207
205
|
const count = displayed.length;
|
|
208
|
-
const { title, msg
|
|
206
|
+
const { title, msg } = makePickupMesssaging(address, latLng, count, minDistance, maxDistance);
|
|
207
|
+
const error = null;
|
|
209
208
|
return { title, msg, error, displayed };
|
|
210
209
|
}
|
|
211
210
|
};
|
|
@@ -256,8 +255,6 @@ export const LOCATIONS_MESSAGES = {
|
|
|
256
255
|
}
|
|
257
256
|
};
|
|
258
257
|
export const renameLocation = (str, names) => {
|
|
259
|
-
if (!isString(str))
|
|
260
|
-
return str;
|
|
261
258
|
const [singular, plural] = names;
|
|
262
259
|
return str
|
|
263
260
|
.replace('1 locations', '1 location')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.98",
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"typescript": "^4.8.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@open-tender/types": "^0.
|
|
56
|
+
"@open-tender/types": "^0.2.43",
|
|
57
57
|
"@reduxjs/toolkit": "^1.8.5",
|
|
58
58
|
"react": "^18.2.0"
|
|
59
59
|
},
|