@open-tender/utils 0.1.2 → 0.1.4
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/hooks/menu/useOrderItem.d.ts +1 -1
- package/dist/cjs/hooks/menu/useOrderItem.js +2 -2
- package/dist/cjs/utils/helpers.d.ts +6 -1
- package/dist/cjs/utils/helpers.js +10 -1
- package/dist/esm/hooks/menu/useOrderItem.d.ts +1 -1
- package/dist/esm/hooks/menu/useOrderItem.js +2 -2
- package/dist/esm/utils/helpers.d.ts +6 -1
- package/dist/esm/utils/helpers.js +8 -0
- package/package.json +1 -1
- package/dist/cjs/utils/platform.d.ts +0 -0
- package/dist/cjs/utils/platform.js +0 -1
- package/dist/esm/utils/platform.d.ts +0 -0
- package/dist/esm/utils/platform.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CartCounts, Favorite, CartItem, ConfigDisplaySetting } from '@open-tender/types';
|
|
2
|
-
export declare const useOrderItem: (orderItem: CartItem, favorite
|
|
2
|
+
export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | null, allergenAlerts?: string[], displaySettings?: ConfigDisplaySetting | null, cartCounts?: CartCounts, isMobile?: boolean) => {
|
|
3
3
|
showImage: boolean;
|
|
4
4
|
displayDesc: string | null;
|
|
5
5
|
displayTags: string[];
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOrderItem = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
|
-
const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySettings, cartCounts = {}, isMobile = true) => {
|
|
6
|
-
const { menuImages: showImage, calories: showCals, tags: showTags, allergens: showAllergens, quickAdd, quickAddMobile, menuItemDescription, menuItemDescriptionMobile } = displaySettings;
|
|
5
|
+
const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySettings = null, cartCounts = {}, isMobile = true) => {
|
|
6
|
+
const { menuImages: showImage = true, calories: showCals = false, tags: showTags = false, allergens: showAllergens = false, quickAdd = false, quickAddMobile = false, menuItemDescription = 'SHOW', menuItemDescriptionMobile = 'SHOW' } = displaySettings || {};
|
|
7
7
|
const showQuickAdd = isMobile ? quickAddMobile : quickAdd;
|
|
8
8
|
const { description, shortDescription, quantity, price, totalPrice, cals, totalCals, tags, allergens, groups, isSoldOut } = orderItem;
|
|
9
9
|
const cartCount = cartCounts[orderItem.id] || 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Announcements, ContentImages, GuestData } from '@open-tender/types';
|
|
1
|
+
import { Announcements, ContentImages, GuestData, 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;
|
|
@@ -35,3 +35,8 @@ export declare const addCommas: (x: number, d: number) => string;
|
|
|
35
35
|
export declare const formatQuantity: (n: string) => string;
|
|
36
36
|
export declare const formatDollars: (str: string, space?: string, decimals?: number) => string;
|
|
37
37
|
export declare const convertStringToArray: (str: string | null) => string[];
|
|
38
|
+
export declare const hasEntities: <T extends unknown[]>(reducer: {
|
|
39
|
+
entities: T;
|
|
40
|
+
loading: RequestStatus;
|
|
41
|
+
error: RequestError;
|
|
42
|
+
}) => number | false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertStringToArray = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.displayPrice = exports.makeSlides = exports.makeImageUrl = exports.getHeight = exports.getWidth = exports.makeRandomNumberString = 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;
|
|
3
|
+
exports.hasEntities = exports.convertStringToArray = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.displayPrice = exports.makeSlides = exports.makeImageUrl = exports.getHeight = exports.getWidth = exports.makeRandomNumberString = 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
|
};
|
|
@@ -178,3 +178,12 @@ const convertStringToArray = (str) => {
|
|
|
178
178
|
: [];
|
|
179
179
|
};
|
|
180
180
|
exports.convertStringToArray = convertStringToArray;
|
|
181
|
+
const hasEntities = (reducer) => {
|
|
182
|
+
if (!reducer)
|
|
183
|
+
return false;
|
|
184
|
+
const { entities, loading, error } = reducer;
|
|
185
|
+
if (loading === 'pending' && !entities.length)
|
|
186
|
+
return false;
|
|
187
|
+
return !error && entities.length;
|
|
188
|
+
};
|
|
189
|
+
exports.hasEntities = hasEntities;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CartCounts, Favorite, CartItem, ConfigDisplaySetting } from '@open-tender/types';
|
|
2
|
-
export declare const useOrderItem: (orderItem: CartItem, favorite
|
|
2
|
+
export declare const useOrderItem: (orderItem: CartItem, favorite?: Favorite | null, allergenAlerts?: string[], displaySettings?: ConfigDisplaySetting | null, cartCounts?: CartCounts, isMobile?: boolean) => {
|
|
3
3
|
showImage: boolean;
|
|
4
4
|
displayDesc: string | null;
|
|
5
5
|
displayTags: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatDollars, getItemOptions, hasGroupsBelowMin } from '../../utils';
|
|
2
|
-
export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySettings, cartCounts = {}, isMobile = true) => {
|
|
3
|
-
const { menuImages: showImage, calories: showCals, tags: showTags, allergens: showAllergens, quickAdd, quickAddMobile, menuItemDescription, menuItemDescriptionMobile } = displaySettings;
|
|
2
|
+
export const useOrderItem = (orderItem, favorite = null, allergenAlerts = [], displaySettings = null, cartCounts = {}, isMobile = true) => {
|
|
3
|
+
const { menuImages: showImage = true, calories: showCals = false, tags: showTags = false, allergens: showAllergens = false, quickAdd = false, quickAddMobile = false, menuItemDescription = 'SHOW', menuItemDescriptionMobile = 'SHOW' } = displaySettings || {};
|
|
4
4
|
const showQuickAdd = isMobile ? quickAddMobile : quickAdd;
|
|
5
5
|
const { description, shortDescription, quantity, price, totalPrice, cals, totalCals, tags, allergens, groups, isSoldOut } = orderItem;
|
|
6
6
|
const cartCount = cartCounts[orderItem.id] || 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Announcements, ContentImages, GuestData } from '@open-tender/types';
|
|
1
|
+
import { Announcements, ContentImages, GuestData, 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;
|
|
@@ -35,3 +35,8 @@ export declare const addCommas: (x: number, d: number) => string;
|
|
|
35
35
|
export declare const formatQuantity: (n: string) => string;
|
|
36
36
|
export declare const formatDollars: (str: string, space?: string, decimals?: number) => string;
|
|
37
37
|
export declare const convertStringToArray: (str: string | null) => string[];
|
|
38
|
+
export declare const hasEntities: <T extends unknown[]>(reducer: {
|
|
39
|
+
entities: T;
|
|
40
|
+
loading: RequestStatus;
|
|
41
|
+
error: RequestError;
|
|
42
|
+
}) => number | false;
|
|
@@ -147,3 +147,11 @@ export const convertStringToArray = (str) => {
|
|
|
147
147
|
.filter(i => i.length)
|
|
148
148
|
: [];
|
|
149
149
|
};
|
|
150
|
+
export const hasEntities = (reducer) => {
|
|
151
|
+
if (!reducer)
|
|
152
|
+
return false;
|
|
153
|
+
const { entities, loading, error } = reducer;
|
|
154
|
+
if (loading === 'pending' && !entities.length)
|
|
155
|
+
return false;
|
|
156
|
+
return !error && entities.length;
|
|
157
|
+
};
|
package/package.json
CHANGED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|