@open-tender/utils 0.4.62 → 0.4.63

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.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useCreditCard = void 0;
4
4
  const react_1 = require("react");
5
- const __1 = require("..");
5
+ const index_1 = require("../index");
6
6
  const defaultState = {
7
7
  acct: '',
8
8
  exp: '',
@@ -19,7 +19,7 @@ const defaulStateAddress = {
19
19
  is_default: false
20
20
  };
21
21
  const useCreditCard = (initState, cardErrors = {}, disabled = false, includeAddress = false) => {
22
- const [initCard, initCardType] = (0, __1.formatCard)(initState);
22
+ const [initCard, initCardType] = (0, index_1.formatCard)(initState);
23
23
  const submitRef = (0, react_1.useRef)(null);
24
24
  const defaultCard = includeAddress ? defaulStateAddress : defaultState;
25
25
  const [data, setData] = (0, react_1.useState)(initCard || defaultCard);
@@ -27,19 +27,19 @@ const useCreditCard = (initState, cardErrors = {}, disabled = false, includeAddr
27
27
  const [errors, setErrors] = (0, react_1.useState)(cardErrors);
28
28
  const { acct, addr, exp, cvv, zip } = data;
29
29
  const addrComplete = includeAddress ? addr : true;
30
- const isComplete = acct && exp && cvv && zip && addrComplete && (0, __1.isEmpty)(errors) ? true : false;
30
+ const isComplete = acct && exp && cvv && zip && addrComplete && (0, index_1.isEmpty)(errors) ? true : false;
31
31
  const handleChange = (name, value) => {
32
32
  if (name === 'acct') {
33
- const currentType = (0, __1.getCardType)(value.replace(/\s/g, ''));
33
+ const currentType = (0, index_1.getCardType)(value.replace(/\s/g, ''));
34
34
  setCardType(currentType);
35
35
  }
36
36
  if (name !== 'is_default') {
37
- value = (0, __1.formatCardField)(name, value);
37
+ value = (0, index_1.formatCardField)(name, value);
38
38
  }
39
39
  setData(Object.assign(Object.assign({}, data), { [name]: value }));
40
40
  };
41
41
  const handleBlur = (name) => {
42
- const { errors: validationErrors } = (0, __1.validateCreditCard)(data, cardType);
42
+ const { errors: validationErrors } = (0, index_1.validateCreditCard)(data, cardType);
43
43
  if (validationErrors) {
44
44
  const error = validationErrors[name];
45
45
  setErrors(Object.assign(Object.assign({}, errors), { [name]: error }));
@@ -1,5 +1,5 @@
1
1
  import { useRef, useState } from 'react';
2
- import { formatCardField, formatCard, getCardType, isEmpty, validateCreditCard } from '..';
2
+ import { formatCardField, formatCard, getCardType, isEmpty, validateCreditCard } from '../index';
3
3
  const defaultState = {
4
4
  acct: '',
5
5
  exp: '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.4.62",
3
+ "version": "0.4.63",
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",
@@ -65,5 +65,6 @@
65
65
  "dependencies": {
66
66
  "date-fns": "^2.29.3",
67
67
  "date-fns-tz": "^1.3.7"
68
- }
68
+ },
69
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
69
70
  }