@open-tender/utils 0.1.119 → 0.1.121
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/hooks/useMenuItem.d.ts +1 -0
- package/dist/cjs/hooks/useMenuItem.js +6 -1
- package/dist/cjs/utils/menu.d.ts +6 -4
- package/dist/cjs/utils/menu.js +3 -3
- package/dist/esm/hooks/useMenuItem.d.ts +1 -0
- package/dist/esm/hooks/useMenuItem.js +7 -2
- package/dist/esm/utils/menu.d.ts +6 -4
- package/dist/esm/utils/menu.js +1 -1
- package/package.json +1 -1
package/dist/.DS_Store
CHANGED
|
Binary file
|
|
@@ -22,6 +22,7 @@ export declare const useMenuItem: (builtItem: CartItem, auth: Auth | null, looku
|
|
|
22
22
|
hasInfo: boolean | "" | null;
|
|
23
23
|
hasMadeFor: boolean;
|
|
24
24
|
hasNotes: boolean;
|
|
25
|
+
hasSelections: boolean;
|
|
25
26
|
cartGuestId: number | null;
|
|
26
27
|
customerId: number | null;
|
|
27
28
|
index?: number | undefined;
|
|
@@ -30,6 +30,10 @@ const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) => {
|
|
|
30
30
|
const isIncomplete = totalPrice === 0 || quantity === 0 || groupsBelowMin;
|
|
31
31
|
const requiresCustomization = isIncomplete && !missingSize;
|
|
32
32
|
const nonSizeGroups = groups ? groups.filter(i => !i.isSize) : null;
|
|
33
|
+
const currentOptions = nonSizeGroups
|
|
34
|
+
? (0, utils_1.getItemOptions)(Object.assign(Object.assign({}, builtItem), { groups: nonSizeGroups }))
|
|
35
|
+
: [];
|
|
36
|
+
const hasSelections = currentOptions.length > 0;
|
|
33
37
|
const hasMadeFor = showMadeFor && !cartId ? true : false;
|
|
34
38
|
const hasNotes = showNotes ? true : false;
|
|
35
39
|
const hasIngredients = ingredients && ingredients.length > 0;
|
|
@@ -56,6 +60,7 @@ const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) => {
|
|
|
56
60
|
hasIngredients,
|
|
57
61
|
hasInfo,
|
|
58
62
|
hasMadeFor,
|
|
59
|
-
hasNotes
|
|
63
|
+
hasNotes,
|
|
64
|
+
hasSelections });
|
|
60
65
|
};
|
|
61
66
|
exports.useMenuItem = useMenuItem;
|
package/dist/cjs/utils/menu.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { MenuCategories, MenuDisplayedSections
|
|
1
|
+
import { MenuCategories, MenuDisplayedSections } from '@open-tender/types';
|
|
2
2
|
export declare const getBinaryArr: <T>(arr: T[]) => T[][];
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const makeItemChunks: <T extends {
|
|
4
|
+
id: number;
|
|
5
|
+
}>(items: T[], chunkSize: number) => {
|
|
4
6
|
key: string;
|
|
5
|
-
items:
|
|
7
|
+
items: T[];
|
|
6
8
|
}[];
|
|
7
9
|
export declare const makeOtherMenuSections: (displayedSections: MenuDisplayedSections, length?: number) => {
|
|
8
10
|
name: string;
|
|
@@ -90,7 +92,7 @@ export declare const makeFlatCategories: (categories: MenuCategories) => {
|
|
|
90
92
|
children: MenuCategories;
|
|
91
93
|
description: string | null;
|
|
92
94
|
id: number;
|
|
93
|
-
items: MenuItems;
|
|
95
|
+
items: import("@open-tender/types").MenuItems;
|
|
94
96
|
large_image_url: string | null;
|
|
95
97
|
menu_name: string;
|
|
96
98
|
menu_name_id: number;
|
package/dist/cjs/utils/menu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeFlatCategories = exports.makeOtherMenuSections = exports.
|
|
3
|
+
exports.makeFlatCategories = exports.makeOtherMenuSections = exports.makeItemChunks = exports.getBinaryArr = void 0;
|
|
4
4
|
const helpers_1 = require("./helpers");
|
|
5
5
|
const getBinaryArr = (arr) => {
|
|
6
6
|
const result = [];
|
|
@@ -12,7 +12,7 @@ const getBinaryArr = (arr) => {
|
|
|
12
12
|
return result;
|
|
13
13
|
};
|
|
14
14
|
exports.getBinaryArr = getBinaryArr;
|
|
15
|
-
const
|
|
15
|
+
const makeItemChunks = (items, chunkSize) => {
|
|
16
16
|
const arr = [];
|
|
17
17
|
for (let i = 0; i < items.length; i += chunkSize) {
|
|
18
18
|
const chunk = items.slice(i, i + chunkSize);
|
|
@@ -21,7 +21,7 @@ const makeMenuItemChunks = (items, chunkSize) => {
|
|
|
21
21
|
}
|
|
22
22
|
return arr;
|
|
23
23
|
};
|
|
24
|
-
exports.
|
|
24
|
+
exports.makeItemChunks = makeItemChunks;
|
|
25
25
|
const makeOtherMenuSections = (displayedSections, length = 10) => {
|
|
26
26
|
return Object.entries(displayedSections).map(([section, items]) => {
|
|
27
27
|
const slug = (0, helpers_1.slugify)(section);
|
|
@@ -22,6 +22,7 @@ export declare const useMenuItem: (builtItem: CartItem, auth: Auth | null, looku
|
|
|
22
22
|
hasInfo: boolean | "" | null;
|
|
23
23
|
hasMadeFor: boolean;
|
|
24
24
|
hasNotes: boolean;
|
|
25
|
+
hasSelections: boolean;
|
|
25
26
|
cartGuestId: number | null;
|
|
26
27
|
customerId: number | null;
|
|
27
28
|
index?: number | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatDollars, hasGroupsBelowMin, makeItemSignature } from '../utils';
|
|
1
|
+
import { formatDollars, getItemOptions, hasGroupsBelowMin, makeItemSignature } from '../utils';
|
|
2
2
|
export const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) => {
|
|
3
3
|
const signature = makeItemSignature(builtItem);
|
|
4
4
|
const favoriteId = lookup && signature ? lookup[signature] : null;
|
|
@@ -27,6 +27,10 @@ export const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) =>
|
|
|
27
27
|
const isIncomplete = totalPrice === 0 || quantity === 0 || groupsBelowMin;
|
|
28
28
|
const requiresCustomization = isIncomplete && !missingSize;
|
|
29
29
|
const nonSizeGroups = groups ? groups.filter(i => !i.isSize) : null;
|
|
30
|
+
const currentOptions = nonSizeGroups
|
|
31
|
+
? getItemOptions(Object.assign(Object.assign({}, builtItem), { groups: nonSizeGroups }))
|
|
32
|
+
: [];
|
|
33
|
+
const hasSelections = currentOptions.length > 0;
|
|
30
34
|
const hasMadeFor = showMadeFor && !cartId ? true : false;
|
|
31
35
|
const hasNotes = showNotes ? true : false;
|
|
32
36
|
const hasIngredients = ingredients && ingredients.length > 0;
|
|
@@ -53,5 +57,6 @@ export const useMenuItem = (builtItem, auth, lookup, cartId, displaySettings) =>
|
|
|
53
57
|
hasIngredients,
|
|
54
58
|
hasInfo,
|
|
55
59
|
hasMadeFor,
|
|
56
|
-
hasNotes
|
|
60
|
+
hasNotes,
|
|
61
|
+
hasSelections });
|
|
57
62
|
};
|
package/dist/esm/utils/menu.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { MenuCategories, MenuDisplayedSections
|
|
1
|
+
import { MenuCategories, MenuDisplayedSections } from '@open-tender/types';
|
|
2
2
|
export declare const getBinaryArr: <T>(arr: T[]) => T[][];
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const makeItemChunks: <T extends {
|
|
4
|
+
id: number;
|
|
5
|
+
}>(items: T[], chunkSize: number) => {
|
|
4
6
|
key: string;
|
|
5
|
-
items:
|
|
7
|
+
items: T[];
|
|
6
8
|
}[];
|
|
7
9
|
export declare const makeOtherMenuSections: (displayedSections: MenuDisplayedSections, length?: number) => {
|
|
8
10
|
name: string;
|
|
@@ -90,7 +92,7 @@ export declare const makeFlatCategories: (categories: MenuCategories) => {
|
|
|
90
92
|
children: MenuCategories;
|
|
91
93
|
description: string | null;
|
|
92
94
|
id: number;
|
|
93
|
-
items: MenuItems;
|
|
95
|
+
items: import("@open-tender/types").MenuItems;
|
|
94
96
|
large_image_url: string | null;
|
|
95
97
|
menu_name: string;
|
|
96
98
|
menu_name_id: number;
|
package/dist/esm/utils/menu.js
CHANGED
|
@@ -8,7 +8,7 @@ export const getBinaryArr = (arr) => {
|
|
|
8
8
|
}
|
|
9
9
|
return result;
|
|
10
10
|
};
|
|
11
|
-
export const
|
|
11
|
+
export const makeItemChunks = (items, chunkSize) => {
|
|
12
12
|
const arr = [];
|
|
13
13
|
for (let i = 0; i < items.length; i += chunkSize) {
|
|
14
14
|
const chunk = items.slice(i, i + chunkSize);
|
package/package.json
CHANGED