@open-tender/utils 0.1.113 → 0.1.114
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/helpers.d.ts +1 -48
- package/dist/cjs/utils/helpers.js +1 -35
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/menu.d.ts +104 -0
- package/dist/cjs/utils/menu.js +47 -0
- package/dist/esm/utils/helpers.d.ts +1 -48
- package/dist/esm/utils/helpers.js +0 -31
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/menu.d.ts +104 -0
- package/dist/esm/utils/menu.js +40 -0
- package/package.json +1 -1
package/dist/.DS_Store
ADDED
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images,
|
|
1
|
+
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
2
|
export declare const isString: (str: any) => boolean;
|
|
3
3
|
export declare const isObject: (obj: any) => boolean;
|
|
4
4
|
export declare const isEmpty: (obj?: object | null) => boolean;
|
|
@@ -46,50 +46,3 @@ export declare const hasEntities: <T extends unknown[]>(reducer: {
|
|
|
46
46
|
loading: RequestStatus;
|
|
47
47
|
error: RequestError;
|
|
48
48
|
}) => number | false;
|
|
49
|
-
export declare const getBinaryArr: <T>(arr: T[]) => T[][];
|
|
50
|
-
export declare const makeMenuItemChunks: (items: MenuItems, chunkSize: number) => {
|
|
51
|
-
key: string;
|
|
52
|
-
items: import("@open-tender/types").MenuItem[];
|
|
53
|
-
}[];
|
|
54
|
-
export declare const makeOtherSections: (displayedSections: MenuDisplayedSections, length?: number) => {
|
|
55
|
-
name: string;
|
|
56
|
-
id: string;
|
|
57
|
-
key: string;
|
|
58
|
-
data: {
|
|
59
|
-
key: string;
|
|
60
|
-
allergens: string | null;
|
|
61
|
-
app_image_url: string | null;
|
|
62
|
-
calories: number | null;
|
|
63
|
-
description: string | null;
|
|
64
|
-
dimensions: number[] | null;
|
|
65
|
-
featured_position: number | null;
|
|
66
|
-
id: number;
|
|
67
|
-
increment: number;
|
|
68
|
-
ingredients: string | null;
|
|
69
|
-
is_alcohol: boolean;
|
|
70
|
-
item_id: number;
|
|
71
|
-
large_image_url: string | null;
|
|
72
|
-
max_quantity: number;
|
|
73
|
-
menu_position: number;
|
|
74
|
-
min_quantity: number;
|
|
75
|
-
name: string;
|
|
76
|
-
nutritional_info: import("@open-tender/types").NutritionalInfo | null;
|
|
77
|
-
option_groups: import("@open-tender/types").MenuItemGroups;
|
|
78
|
-
plu: string | null;
|
|
79
|
-
points: number | null;
|
|
80
|
-
pos_display_color: string | null;
|
|
81
|
-
price: string;
|
|
82
|
-
sales_tax_override: `${number}.${number}` | null;
|
|
83
|
-
short_description: string | null;
|
|
84
|
-
short_name: string;
|
|
85
|
-
shorthand: string | null;
|
|
86
|
-
similar_items: number[];
|
|
87
|
-
slug: string;
|
|
88
|
-
small_image_url: string | null;
|
|
89
|
-
suspend_until: number | null;
|
|
90
|
-
tags: string | null;
|
|
91
|
-
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
92
|
-
temperature: import("@open-tender/types").Temperature;
|
|
93
|
-
upsell_items: number[];
|
|
94
|
-
}[];
|
|
95
|
-
}[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.hasEntities = exports.convertStringToArray = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.displayPrice = exports.makeSlides = exports.makeImageUrl = exports.makeImageMap = exports.getHeight = exports.getWidth = exports.makeRandomNumberString = exports.checkNotFound = exports.checkGuestData = exports.checkEmpty = exports.validateEmail = exports.dashesToSlashes = exports.slashesToDashes = exports.makeBirthDate = exports.validatePhone = exports.makePhone = exports.cleanPhone = exports.capitalize = exports.serialize = exports.stripTags = exports.slugify = exports.contains = exports.isNum = exports.isEmpty = exports.isObject = exports.isString = void 0;
|
|
4
4
|
const isString = (str) => {
|
|
5
5
|
return typeof str === 'string';
|
|
6
6
|
};
|
|
@@ -201,37 +201,3 @@ const hasEntities = (reducer) => {
|
|
|
201
201
|
return !error && entities.length;
|
|
202
202
|
};
|
|
203
203
|
exports.hasEntities = hasEntities;
|
|
204
|
-
const getBinaryArr = (arr) => {
|
|
205
|
-
const result = [];
|
|
206
|
-
for (let i = 0; i < arr.length; i += 2) {
|
|
207
|
-
const firstItem = arr[i];
|
|
208
|
-
const secondItem = arr[i + 1];
|
|
209
|
-
result.push(secondItem ? [firstItem, secondItem] : [firstItem]);
|
|
210
|
-
}
|
|
211
|
-
return result;
|
|
212
|
-
};
|
|
213
|
-
exports.getBinaryArr = getBinaryArr;
|
|
214
|
-
const makeMenuItemChunks = (items, chunkSize) => {
|
|
215
|
-
const arr = [];
|
|
216
|
-
for (let i = 0; i < items.length; i += chunkSize) {
|
|
217
|
-
const chunk = items.slice(i, i + chunkSize);
|
|
218
|
-
const key = chunk.map((item, index) => `${i + index}-${item.id}`).join('-');
|
|
219
|
-
arr.push({ key, items: chunk });
|
|
220
|
-
}
|
|
221
|
-
return arr;
|
|
222
|
-
};
|
|
223
|
-
exports.makeMenuItemChunks = makeMenuItemChunks;
|
|
224
|
-
const makeOtherSections = (displayedSections, length = 10) => {
|
|
225
|
-
return Object.entries(displayedSections).map(([section, items]) => {
|
|
226
|
-
const slug = (0, exports.slugify)(section);
|
|
227
|
-
return {
|
|
228
|
-
name: (0, exports.capitalize)(section),
|
|
229
|
-
id: slug,
|
|
230
|
-
key: slug,
|
|
231
|
-
data: items
|
|
232
|
-
.map((i, idx) => (Object.assign(Object.assign({}, i), { key: `${slug}-${i.id}-${idx}` })))
|
|
233
|
-
.slice(0, length)
|
|
234
|
-
};
|
|
235
|
-
});
|
|
236
|
-
};
|
|
237
|
-
exports.makeOtherSections = makeOtherSections;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -12,6 +12,7 @@ tslib_1.__exportStar(require("./googleMaps"), exports);
|
|
|
12
12
|
tslib_1.__exportStar(require("./helpers"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./keypad"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./maps"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./menu"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./revenueCenters"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./refunds"), exports);
|
|
17
18
|
tslib_1.__exportStar(require("./rewards"), exports);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { MenuCategories, MenuDisplayedSections, MenuItems } from '@open-tender/types';
|
|
2
|
+
export declare const getBinaryArr: <T>(arr: T[]) => T[][];
|
|
3
|
+
export declare const makeMenuItemChunks: (items: MenuItems, chunkSize: number) => {
|
|
4
|
+
key: string;
|
|
5
|
+
items: import("@open-tender/types").MenuItem[];
|
|
6
|
+
}[];
|
|
7
|
+
export declare const makeOtherMenuSections: (displayedSections: MenuDisplayedSections, length?: number) => {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string;
|
|
10
|
+
key: string;
|
|
11
|
+
data: {
|
|
12
|
+
key: string;
|
|
13
|
+
allergens: string | null;
|
|
14
|
+
app_image_url: string | null;
|
|
15
|
+
calories: number | null;
|
|
16
|
+
description: string | null;
|
|
17
|
+
dimensions: number[] | null;
|
|
18
|
+
featured_position: number | null;
|
|
19
|
+
id: number;
|
|
20
|
+
increment: number;
|
|
21
|
+
ingredients: string | null;
|
|
22
|
+
is_alcohol: boolean;
|
|
23
|
+
item_id: number;
|
|
24
|
+
large_image_url: string | null;
|
|
25
|
+
max_quantity: number;
|
|
26
|
+
menu_position: number;
|
|
27
|
+
min_quantity: number;
|
|
28
|
+
name: string;
|
|
29
|
+
nutritional_info: import("@open-tender/types").NutritionalInfo | null;
|
|
30
|
+
option_groups: import("@open-tender/types").MenuItemGroups;
|
|
31
|
+
plu: string | null;
|
|
32
|
+
points: number | null;
|
|
33
|
+
pos_display_color: string | null;
|
|
34
|
+
price: string;
|
|
35
|
+
sales_tax_override: `${number}.${number}` | null;
|
|
36
|
+
short_description: string | null;
|
|
37
|
+
short_name: string;
|
|
38
|
+
shorthand: string | null;
|
|
39
|
+
similar_items: number[];
|
|
40
|
+
slug: string;
|
|
41
|
+
small_image_url: string | null;
|
|
42
|
+
suspend_until: number | null;
|
|
43
|
+
tags: string | null;
|
|
44
|
+
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
45
|
+
temperature: import("@open-tender/types").Temperature;
|
|
46
|
+
upsell_items: number[];
|
|
47
|
+
}[];
|
|
48
|
+
}[];
|
|
49
|
+
export declare const makeFlatCategories: (categories: MenuCategories) => {
|
|
50
|
+
key: string;
|
|
51
|
+
data: {
|
|
52
|
+
key: string;
|
|
53
|
+
allergens: string | null;
|
|
54
|
+
app_image_url: string | null;
|
|
55
|
+
calories: number | null;
|
|
56
|
+
description: string | null;
|
|
57
|
+
dimensions: number[] | null;
|
|
58
|
+
featured_position: number | null;
|
|
59
|
+
id: number;
|
|
60
|
+
increment: number;
|
|
61
|
+
ingredients: string | null;
|
|
62
|
+
is_alcohol: boolean;
|
|
63
|
+
item_id: number;
|
|
64
|
+
large_image_url: string | null;
|
|
65
|
+
max_quantity: number;
|
|
66
|
+
menu_position: number;
|
|
67
|
+
min_quantity: number;
|
|
68
|
+
name: string;
|
|
69
|
+
nutritional_info: import("@open-tender/types").NutritionalInfo | null;
|
|
70
|
+
option_groups: import("@open-tender/types").MenuItemGroups;
|
|
71
|
+
plu: string | null;
|
|
72
|
+
points: number | null;
|
|
73
|
+
pos_display_color: string | null;
|
|
74
|
+
price: string;
|
|
75
|
+
sales_tax_override: `${number}.${number}` | null;
|
|
76
|
+
short_description: string | null;
|
|
77
|
+
short_name: string;
|
|
78
|
+
shorthand: string | null;
|
|
79
|
+
similar_items: number[];
|
|
80
|
+
slug: string;
|
|
81
|
+
small_image_url: string | null;
|
|
82
|
+
suspend_until: number | null;
|
|
83
|
+
tags: string | null;
|
|
84
|
+
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
85
|
+
temperature: import("@open-tender/types").Temperature;
|
|
86
|
+
upsell_items: number[];
|
|
87
|
+
}[];
|
|
88
|
+
app_image_url: string | null;
|
|
89
|
+
appearance: import("@open-tender/types").MenuCategoryAppearance;
|
|
90
|
+
children: MenuCategories;
|
|
91
|
+
description: string | null;
|
|
92
|
+
id: number;
|
|
93
|
+
items: MenuItems;
|
|
94
|
+
large_image_url: string | null;
|
|
95
|
+
menu_name: string;
|
|
96
|
+
menu_name_id: number;
|
|
97
|
+
menu_position: number;
|
|
98
|
+
name: string;
|
|
99
|
+
pos: import("@open-tender/types").MenuCategoryPos | null;
|
|
100
|
+
revenue_center_id: number | null;
|
|
101
|
+
short_name: string;
|
|
102
|
+
slug: string;
|
|
103
|
+
small_image_url: string | null;
|
|
104
|
+
}[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeFlatCategories = exports.makeOtherMenuSections = exports.makeMenuItemChunks = exports.getBinaryArr = void 0;
|
|
4
|
+
const helpers_1 = require("./helpers");
|
|
5
|
+
const getBinaryArr = (arr) => {
|
|
6
|
+
const result = [];
|
|
7
|
+
for (let i = 0; i < arr.length; i += 2) {
|
|
8
|
+
const firstItem = arr[i];
|
|
9
|
+
const secondItem = arr[i + 1];
|
|
10
|
+
result.push(secondItem ? [firstItem, secondItem] : [firstItem]);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
exports.getBinaryArr = getBinaryArr;
|
|
15
|
+
const makeMenuItemChunks = (items, chunkSize) => {
|
|
16
|
+
const arr = [];
|
|
17
|
+
for (let i = 0; i < items.length; i += chunkSize) {
|
|
18
|
+
const chunk = items.slice(i, i + chunkSize);
|
|
19
|
+
const key = chunk.map((item, index) => `${i + index}-${item.id}`).join('-');
|
|
20
|
+
arr.push({ key, items: chunk });
|
|
21
|
+
}
|
|
22
|
+
return arr;
|
|
23
|
+
};
|
|
24
|
+
exports.makeMenuItemChunks = makeMenuItemChunks;
|
|
25
|
+
const makeOtherMenuSections = (displayedSections, length = 10) => {
|
|
26
|
+
return Object.entries(displayedSections).map(([section, items]) => {
|
|
27
|
+
const slug = (0, helpers_1.slugify)(section);
|
|
28
|
+
return {
|
|
29
|
+
name: (0, helpers_1.capitalize)(section),
|
|
30
|
+
id: slug,
|
|
31
|
+
key: slug,
|
|
32
|
+
data: items
|
|
33
|
+
.map((i, idx) => (Object.assign(Object.assign({}, i), { key: `${slug}-${i.id}-${idx}` })))
|
|
34
|
+
.slice(0, length)
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.makeOtherMenuSections = makeOtherMenuSections;
|
|
39
|
+
const makeFlatCategories = (categories) => {
|
|
40
|
+
return categories
|
|
41
|
+
.reduce((arr, cat) => {
|
|
42
|
+
return [...arr, cat, ...(cat.children || [])];
|
|
43
|
+
}, [])
|
|
44
|
+
.filter(c => c.items.length)
|
|
45
|
+
.map(c => (Object.assign(Object.assign({}, c), { key: (0, helpers_1.slugify)(c.name), data: c.items.map((i, idx) => (Object.assign(Object.assign({}, i), { key: `${(0, helpers_1.slugify)(c.name)}-${i.id}-${idx}` }))) })));
|
|
46
|
+
};
|
|
47
|
+
exports.makeFlatCategories = makeFlatCategories;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images,
|
|
1
|
+
import { Announcements, CheckoutFormCustomer, ContentImages, DateString, Images, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
2
|
export declare const isString: (str: any) => boolean;
|
|
3
3
|
export declare const isObject: (obj: any) => boolean;
|
|
4
4
|
export declare const isEmpty: (obj?: object | null) => boolean;
|
|
@@ -46,50 +46,3 @@ export declare const hasEntities: <T extends unknown[]>(reducer: {
|
|
|
46
46
|
loading: RequestStatus;
|
|
47
47
|
error: RequestError;
|
|
48
48
|
}) => number | false;
|
|
49
|
-
export declare const getBinaryArr: <T>(arr: T[]) => T[][];
|
|
50
|
-
export declare const makeMenuItemChunks: (items: MenuItems, chunkSize: number) => {
|
|
51
|
-
key: string;
|
|
52
|
-
items: import("@open-tender/types").MenuItem[];
|
|
53
|
-
}[];
|
|
54
|
-
export declare const makeOtherSections: (displayedSections: MenuDisplayedSections, length?: number) => {
|
|
55
|
-
name: string;
|
|
56
|
-
id: string;
|
|
57
|
-
key: string;
|
|
58
|
-
data: {
|
|
59
|
-
key: string;
|
|
60
|
-
allergens: string | null;
|
|
61
|
-
app_image_url: string | null;
|
|
62
|
-
calories: number | null;
|
|
63
|
-
description: string | null;
|
|
64
|
-
dimensions: number[] | null;
|
|
65
|
-
featured_position: number | null;
|
|
66
|
-
id: number;
|
|
67
|
-
increment: number;
|
|
68
|
-
ingredients: string | null;
|
|
69
|
-
is_alcohol: boolean;
|
|
70
|
-
item_id: number;
|
|
71
|
-
large_image_url: string | null;
|
|
72
|
-
max_quantity: number;
|
|
73
|
-
menu_position: number;
|
|
74
|
-
min_quantity: number;
|
|
75
|
-
name: string;
|
|
76
|
-
nutritional_info: import("@open-tender/types").NutritionalInfo | null;
|
|
77
|
-
option_groups: import("@open-tender/types").MenuItemGroups;
|
|
78
|
-
plu: string | null;
|
|
79
|
-
points: number | null;
|
|
80
|
-
pos_display_color: string | null;
|
|
81
|
-
price: string;
|
|
82
|
-
sales_tax_override: `${number}.${number}` | null;
|
|
83
|
-
short_description: string | null;
|
|
84
|
-
short_name: string;
|
|
85
|
-
shorthand: string | null;
|
|
86
|
-
similar_items: number[];
|
|
87
|
-
slug: string;
|
|
88
|
-
small_image_url: string | null;
|
|
89
|
-
suspend_until: number | null;
|
|
90
|
-
tags: string | null;
|
|
91
|
-
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
92
|
-
temperature: import("@open-tender/types").Temperature;
|
|
93
|
-
upsell_items: number[];
|
|
94
|
-
}[];
|
|
95
|
-
}[];
|
|
@@ -167,34 +167,3 @@ export const hasEntities = (reducer) => {
|
|
|
167
167
|
return false;
|
|
168
168
|
return !error && entities.length;
|
|
169
169
|
};
|
|
170
|
-
export const getBinaryArr = (arr) => {
|
|
171
|
-
const result = [];
|
|
172
|
-
for (let i = 0; i < arr.length; i += 2) {
|
|
173
|
-
const firstItem = arr[i];
|
|
174
|
-
const secondItem = arr[i + 1];
|
|
175
|
-
result.push(secondItem ? [firstItem, secondItem] : [firstItem]);
|
|
176
|
-
}
|
|
177
|
-
return result;
|
|
178
|
-
};
|
|
179
|
-
export const makeMenuItemChunks = (items, chunkSize) => {
|
|
180
|
-
const arr = [];
|
|
181
|
-
for (let i = 0; i < items.length; i += chunkSize) {
|
|
182
|
-
const chunk = items.slice(i, i + chunkSize);
|
|
183
|
-
const key = chunk.map((item, index) => `${i + index}-${item.id}`).join('-');
|
|
184
|
-
arr.push({ key, items: chunk });
|
|
185
|
-
}
|
|
186
|
-
return arr;
|
|
187
|
-
};
|
|
188
|
-
export const makeOtherSections = (displayedSections, length = 10) => {
|
|
189
|
-
return Object.entries(displayedSections).map(([section, items]) => {
|
|
190
|
-
const slug = slugify(section);
|
|
191
|
-
return {
|
|
192
|
-
name: capitalize(section),
|
|
193
|
-
id: slug,
|
|
194
|
-
key: slug,
|
|
195
|
-
data: items
|
|
196
|
-
.map((i, idx) => (Object.assign(Object.assign({}, i), { key: `${slug}-${i.id}-${idx}` })))
|
|
197
|
-
.slice(0, length)
|
|
198
|
-
};
|
|
199
|
-
});
|
|
200
|
-
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { MenuCategories, MenuDisplayedSections, MenuItems } from '@open-tender/types';
|
|
2
|
+
export declare const getBinaryArr: <T>(arr: T[]) => T[][];
|
|
3
|
+
export declare const makeMenuItemChunks: (items: MenuItems, chunkSize: number) => {
|
|
4
|
+
key: string;
|
|
5
|
+
items: import("@open-tender/types").MenuItem[];
|
|
6
|
+
}[];
|
|
7
|
+
export declare const makeOtherMenuSections: (displayedSections: MenuDisplayedSections, length?: number) => {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string;
|
|
10
|
+
key: string;
|
|
11
|
+
data: {
|
|
12
|
+
key: string;
|
|
13
|
+
allergens: string | null;
|
|
14
|
+
app_image_url: string | null;
|
|
15
|
+
calories: number | null;
|
|
16
|
+
description: string | null;
|
|
17
|
+
dimensions: number[] | null;
|
|
18
|
+
featured_position: number | null;
|
|
19
|
+
id: number;
|
|
20
|
+
increment: number;
|
|
21
|
+
ingredients: string | null;
|
|
22
|
+
is_alcohol: boolean;
|
|
23
|
+
item_id: number;
|
|
24
|
+
large_image_url: string | null;
|
|
25
|
+
max_quantity: number;
|
|
26
|
+
menu_position: number;
|
|
27
|
+
min_quantity: number;
|
|
28
|
+
name: string;
|
|
29
|
+
nutritional_info: import("@open-tender/types").NutritionalInfo | null;
|
|
30
|
+
option_groups: import("@open-tender/types").MenuItemGroups;
|
|
31
|
+
plu: string | null;
|
|
32
|
+
points: number | null;
|
|
33
|
+
pos_display_color: string | null;
|
|
34
|
+
price: string;
|
|
35
|
+
sales_tax_override: `${number}.${number}` | null;
|
|
36
|
+
short_description: string | null;
|
|
37
|
+
short_name: string;
|
|
38
|
+
shorthand: string | null;
|
|
39
|
+
similar_items: number[];
|
|
40
|
+
slug: string;
|
|
41
|
+
small_image_url: string | null;
|
|
42
|
+
suspend_until: number | null;
|
|
43
|
+
tags: string | null;
|
|
44
|
+
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
45
|
+
temperature: import("@open-tender/types").Temperature;
|
|
46
|
+
upsell_items: number[];
|
|
47
|
+
}[];
|
|
48
|
+
}[];
|
|
49
|
+
export declare const makeFlatCategories: (categories: MenuCategories) => {
|
|
50
|
+
key: string;
|
|
51
|
+
data: {
|
|
52
|
+
key: string;
|
|
53
|
+
allergens: string | null;
|
|
54
|
+
app_image_url: string | null;
|
|
55
|
+
calories: number | null;
|
|
56
|
+
description: string | null;
|
|
57
|
+
dimensions: number[] | null;
|
|
58
|
+
featured_position: number | null;
|
|
59
|
+
id: number;
|
|
60
|
+
increment: number;
|
|
61
|
+
ingredients: string | null;
|
|
62
|
+
is_alcohol: boolean;
|
|
63
|
+
item_id: number;
|
|
64
|
+
large_image_url: string | null;
|
|
65
|
+
max_quantity: number;
|
|
66
|
+
menu_position: number;
|
|
67
|
+
min_quantity: number;
|
|
68
|
+
name: string;
|
|
69
|
+
nutritional_info: import("@open-tender/types").NutritionalInfo | null;
|
|
70
|
+
option_groups: import("@open-tender/types").MenuItemGroups;
|
|
71
|
+
plu: string | null;
|
|
72
|
+
points: number | null;
|
|
73
|
+
pos_display_color: string | null;
|
|
74
|
+
price: string;
|
|
75
|
+
sales_tax_override: `${number}.${number}` | null;
|
|
76
|
+
short_description: string | null;
|
|
77
|
+
short_name: string;
|
|
78
|
+
shorthand: string | null;
|
|
79
|
+
similar_items: number[];
|
|
80
|
+
slug: string;
|
|
81
|
+
small_image_url: string | null;
|
|
82
|
+
suspend_until: number | null;
|
|
83
|
+
tags: string | null;
|
|
84
|
+
taxes: import("@open-tender/types").MenuItemTaxes;
|
|
85
|
+
temperature: import("@open-tender/types").Temperature;
|
|
86
|
+
upsell_items: number[];
|
|
87
|
+
}[];
|
|
88
|
+
app_image_url: string | null;
|
|
89
|
+
appearance: import("@open-tender/types").MenuCategoryAppearance;
|
|
90
|
+
children: MenuCategories;
|
|
91
|
+
description: string | null;
|
|
92
|
+
id: number;
|
|
93
|
+
items: MenuItems;
|
|
94
|
+
large_image_url: string | null;
|
|
95
|
+
menu_name: string;
|
|
96
|
+
menu_name_id: number;
|
|
97
|
+
menu_position: number;
|
|
98
|
+
name: string;
|
|
99
|
+
pos: import("@open-tender/types").MenuCategoryPos | null;
|
|
100
|
+
revenue_center_id: number | null;
|
|
101
|
+
short_name: string;
|
|
102
|
+
slug: string;
|
|
103
|
+
small_image_url: string | null;
|
|
104
|
+
}[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { capitalize, slugify } from './helpers';
|
|
2
|
+
export const getBinaryArr = (arr) => {
|
|
3
|
+
const result = [];
|
|
4
|
+
for (let i = 0; i < arr.length; i += 2) {
|
|
5
|
+
const firstItem = arr[i];
|
|
6
|
+
const secondItem = arr[i + 1];
|
|
7
|
+
result.push(secondItem ? [firstItem, secondItem] : [firstItem]);
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
export const makeMenuItemChunks = (items, chunkSize) => {
|
|
12
|
+
const arr = [];
|
|
13
|
+
for (let i = 0; i < items.length; i += chunkSize) {
|
|
14
|
+
const chunk = items.slice(i, i + chunkSize);
|
|
15
|
+
const key = chunk.map((item, index) => `${i + index}-${item.id}`).join('-');
|
|
16
|
+
arr.push({ key, items: chunk });
|
|
17
|
+
}
|
|
18
|
+
return arr;
|
|
19
|
+
};
|
|
20
|
+
export const makeOtherMenuSections = (displayedSections, length = 10) => {
|
|
21
|
+
return Object.entries(displayedSections).map(([section, items]) => {
|
|
22
|
+
const slug = slugify(section);
|
|
23
|
+
return {
|
|
24
|
+
name: capitalize(section),
|
|
25
|
+
id: slug,
|
|
26
|
+
key: slug,
|
|
27
|
+
data: items
|
|
28
|
+
.map((i, idx) => (Object.assign(Object.assign({}, i), { key: `${slug}-${i.id}-${idx}` })))
|
|
29
|
+
.slice(0, length)
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export const makeFlatCategories = (categories) => {
|
|
34
|
+
return categories
|
|
35
|
+
.reduce((arr, cat) => {
|
|
36
|
+
return [...arr, cat, ...(cat.children || [])];
|
|
37
|
+
}, [])
|
|
38
|
+
.filter(c => c.items.length)
|
|
39
|
+
.map(c => (Object.assign(Object.assign({}, c), { key: slugify(c.name), data: c.items.map((i, idx) => (Object.assign(Object.assign({}, i), { key: `${slugify(c.name)}-${i.id}-${idx}` }))) })));
|
|
40
|
+
};
|
package/package.json
CHANGED