@thecb/components 10.6.6-beta.0 → 10.6.6-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.6.6-beta.0",
3
+ "version": "10.6.6-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -90,6 +90,6 @@
90
90
  "ramda": "^0.27.0",
91
91
  "react-aria-modal": "^4.0.0",
92
92
  "react-pose": "^4.0.10",
93
- "redux-freeform": "^5.9.1-beta.2"
93
+ "redux-freeform": "^5.9.0"
94
94
  }
95
95
  }
@@ -5,8 +5,7 @@ import {
5
5
  hasLength,
6
6
  matchesRegex,
7
7
  dateAfterToday,
8
- isValidMonth,
9
- isNotAmExCard
8
+ isValidMonth
10
9
  } from "redux-freeform";
11
10
  import Checkbox from "../../atoms/checkbox";
12
11
  import CountryDropdown from "../../atoms/country-dropdown";
@@ -43,8 +42,7 @@ const PaymentFormCard = ({
43
42
  saveToWallet,
44
43
  walletCheckboxMarked,
45
44
  deniedCards,
46
- termsContent,
47
- allowAmExCards = true
45
+ termsContent
48
46
  }) => {
49
47
  const { isMobile } = useContext(ThemeContext);
50
48
  const showTerms = !!termsContent;
@@ -57,9 +55,6 @@ const PaymentFormCard = ({
57
55
  )
58
56
  );
59
57
  }
60
- if (!allowAmExCards) {
61
- actions.fields.creditCardNumber.addValidator(isNotAmExCard());
62
- }
63
58
  }, []);
64
59
 
65
60
  useEffect(() => {
@@ -74,11 +69,9 @@ const PaymentFormCard = ({
74
69
  const creditCardNumberErrors = {
75
70
  [required.error]: "Credit card number is required",
76
71
  [hasLength.error]: "Credit card number is invalid",
77
- [isNotAmExCard.error]:
78
- "American Express cards are not available for payment.",
79
72
  [matchesRegex.error]: `${displayCardBrand(
80
73
  fields.creditCardNumber.rawValue
81
- )} is not accepted`
74
+ )} cards are not available for payment`
82
75
  };
83
76
  const expirationDateErrors = {
84
77
  [required.error]: "Expiration date is required",
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { connect } from "react-redux";
3
- import { boolean } from "@storybook/addon-knobs";
3
+ import { boolean, object } from "@storybook/addon-knobs";
4
4
 
5
5
  import PaymentFormCard from "./PaymentFormCard";
6
6
  import page from "../../../../.storybook/page";
@@ -13,6 +13,7 @@ const story = page({
13
13
  mapStateToProps: PaymentFormCardState.mapStateToProps,
14
14
  mapDispatchToProps: PaymentFormCardState.mapDispatchToProps
15
15
  });
16
+
16
17
  export default story;
17
18
 
18
19
  const ConnectedForm = connect(
@@ -21,8 +22,12 @@ const ConnectedForm = connect(
21
22
  )(PaymentFormCard);
22
23
 
23
24
  export const paymentFormCard = () => (
25
+ <ConnectedForm showErrors={boolean("showErrors", false, "props")} />
26
+ );
27
+
28
+ export const paymentFormCardWithDeniedCards = () => (
24
29
  <ConnectedForm
25
30
  showErrors={boolean("showErrors", false, "props")}
26
- allowAmExCards={boolean("allowAmExCards", true, "props")}
31
+ deniedCards={object("deniedCards", ["AMEX"], "props")}
27
32
  />
28
33
  );
@@ -74,7 +74,7 @@ export const displayCardBrand = number => {
74
74
  return "Mastercard";
75
75
  } else if (/^4/.test(number)) {
76
76
  return "Visa";
77
- } else if (/^3[4,7]/.test(number)) {
77
+ } else if (/^3[4,7]\d{13}$/.test(number)) {
78
78
  return "American Express";
79
79
  } else return "Unknown Card";
80
80
  };