@open-tender/utils 0.1.175 → 0.3.2

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.
@@ -5,7 +5,7 @@ interface NotificationCheckbox {
5
5
  name: NotificationChannel;
6
6
  type: string;
7
7
  }
8
- export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hidePassword?: boolean, optionalFields?: string[], notificationChannels?: NotificationChannel[]) => {
8
+ export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hidePassword?: boolean, optionalFields?: string[], notificationChannels?: NotificationChannel[], passwordRequirements?: string) => {
9
9
  submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
10
10
  data: CustomerCreate;
11
11
  comms: NotificationChannel[];
@@ -27,7 +27,7 @@ const notificationChannelFields = [
27
27
  type: 'checkbox'
28
28
  }
29
29
  ];
30
- const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePassword = false, optionalFields, notificationChannels) => {
30
+ const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePassword = false, optionalFields, notificationChannels, passwordRequirements) => {
31
31
  const submitRef = (0, react_1.useRef)(null);
32
32
  const [data, setData] = (0, react_1.useState)(initState);
33
33
  const [comms, setComms] = (0, react_1.useState)([]);
@@ -67,7 +67,7 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePasswo
67
67
  autoComplete: 'email'
68
68
  },
69
69
  {
70
- label: 'Password',
70
+ label: `Password${passwordRequirements || ''}`,
71
71
  name: 'password',
72
72
  type: 'password',
73
73
  required: true,
@@ -176,3 +176,4 @@ export declare const validateCart: (cart: Cart, categories: MenuCategories, sold
176
176
  export declare const getDefaultTip: (config: CheckoutConfig) => string | null;
177
177
  export declare const prepareOrder: (data: OrderData) => OrderCreate;
178
178
  export declare const checkAmountRemaining: (total: Money, tenders: CheckoutTenders) => number;
179
+ export declare const makeDeviceType: (deviceType: string) => "DESKTOP" | "MOBILE" | "TABLET";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkAmountRemaining = exports.prepareOrder = exports.getDefaultTip = exports.validateCart = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.makeCartItemSignature = exports.makeItemSignature = exports.makeFavoritesLookup = exports.makeUniqueDisplayItems = exports.makeDisplayItems = exports.makeDisplayItem = exports.makeDisplayItemGroups = exports.makeItemImageUrl = exports.combineCarts = exports.compareCarts = exports.makeGuestLookup = exports.rehydrateCheckoutForm = exports.rehydrateCart = exports.rehydrateOrderItem = exports.calcCartCounts = exports.makeOrderItem = exports.checkSoldOut = exports.calcPrices = exports.calcNutritionalInfo = exports.calcNutrition = exports.makeUpsellItems = exports.makeModifierGroups = exports.hasGroupsBelowMin = exports.makeModifierNames = exports.getItemOptions = void 0;
3
+ exports.makeDeviceType = exports.checkAmountRemaining = exports.prepareOrder = exports.getDefaultTip = exports.validateCart = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.makeCartItemSignature = exports.makeItemSignature = exports.makeFavoritesLookup = exports.makeUniqueDisplayItems = exports.makeDisplayItems = exports.makeDisplayItem = exports.makeDisplayItemGroups = exports.makeItemImageUrl = exports.combineCarts = exports.compareCarts = exports.makeGuestLookup = exports.rehydrateCheckoutForm = exports.rehydrateCart = exports.rehydrateOrderItem = exports.calcCartCounts = exports.makeOrderItem = exports.checkSoldOut = exports.calcPrices = exports.calcNutritionalInfo = exports.calcNutrition = exports.makeUpsellItems = exports.makeModifierGroups = exports.hasGroupsBelowMin = exports.makeModifierNames = exports.getItemOptions = void 0;
4
4
  const types_1 = require("@open-tender/types");
5
5
  const helpers_1 = require("./helpers");
6
6
  // TODO: refactor for nested mods (if needed)
@@ -836,3 +836,16 @@ const checkAmountRemaining = (total, tenders) => {
836
836
  return Object.is(remaining, -0) ? 0.0 : remaining;
837
837
  };
838
838
  exports.checkAmountRemaining = checkAmountRemaining;
839
+ const makeDeviceType = (deviceType) => {
840
+ switch (deviceType) {
841
+ case 'tablet':
842
+ return 'TABLET';
843
+ case 'mobile':
844
+ return 'MOBILE';
845
+ case 'browser':
846
+ return 'DESKTOP';
847
+ default:
848
+ return 'DESKTOP';
849
+ }
850
+ };
851
+ exports.makeDeviceType = makeDeviceType;
@@ -5,7 +5,7 @@ interface NotificationCheckbox {
5
5
  name: NotificationChannel;
6
6
  type: string;
7
7
  }
8
- export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hidePassword?: boolean, optionalFields?: string[], notificationChannels?: NotificationChannel[]) => {
8
+ export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hidePassword?: boolean, optionalFields?: string[], notificationChannels?: NotificationChannel[], passwordRequirements?: string) => {
9
9
  submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
10
10
  data: CustomerCreate;
11
11
  comms: NotificationChannel[];
@@ -24,7 +24,7 @@ const notificationChannelFields = [
24
24
  type: 'checkbox'
25
25
  }
26
26
  ];
27
- export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePassword = false, optionalFields, notificationChannels) => {
27
+ export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePassword = false, optionalFields, notificationChannels, passwordRequirements) => {
28
28
  const submitRef = useRef(null);
29
29
  const [data, setData] = useState(initState);
30
30
  const [comms, setComms] = useState([]);
@@ -64,7 +64,7 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hid
64
64
  autoComplete: 'email'
65
65
  },
66
66
  {
67
- label: 'Password',
67
+ label: `Password${passwordRequirements || ''}`,
68
68
  name: 'password',
69
69
  type: 'password',
70
70
  required: true,
@@ -176,3 +176,4 @@ export declare const validateCart: (cart: Cart, categories: MenuCategories, sold
176
176
  export declare const getDefaultTip: (config: CheckoutConfig) => string | null;
177
177
  export declare const prepareOrder: (data: OrderData) => OrderCreate;
178
178
  export declare const checkAmountRemaining: (total: Money, tenders: CheckoutTenders) => number;
179
+ export declare const makeDeviceType: (deviceType: string) => "DESKTOP" | "MOBILE" | "TABLET";
@@ -799,3 +799,15 @@ export const checkAmountRemaining = (total, tenders) => {
799
799
  remaining = Math.round((remaining + Number.EPSILON) * 100) / 100;
800
800
  return Object.is(remaining, -0) ? 0.0 : remaining;
801
801
  };
802
+ export const makeDeviceType = (deviceType) => {
803
+ switch (deviceType) {
804
+ case 'tablet':
805
+ return 'TABLET';
806
+ case 'mobile':
807
+ return 'MOBILE';
808
+ case 'browser':
809
+ return 'DESKTOP';
810
+ default:
811
+ return 'DESKTOP';
812
+ }
813
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.175",
3
+ "version": "0.3.2",
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",