@open-tender/utils 0.1.112 → 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/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/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
CHANGED
|
Binary file
|
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;
|
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