@akinon/pz-gpay 1.19.4 → 1.21.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @akinon/pz-gpay
2
2
 
3
+ ## 1.21.0-rc.0
4
+
5
+ ## 1.20.0
6
+
7
+ ### Minor Changes
8
+
9
+ - 6d4d5cb: ZERO-2420: Add error handling
10
+
3
11
  ## 1.19.4
4
12
 
5
13
  ## 1.19.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-gpay",
3
- "version": "1.19.4",
3
+ "version": "1.21.0-rc.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
@@ -13,6 +13,7 @@ import {
13
13
  import { twMerge } from 'tailwind-merge';
14
14
  import { yupResolver } from '@hookform/resolvers/yup';
15
15
  import { Button } from '@akinon/next/components/button';
16
+ import { getPosError } from '@akinon/next/utils';
16
17
 
17
18
  const gpayFormSchema = yup.object();
18
19
 
@@ -35,6 +36,7 @@ type GpayOptionProps = {
35
36
 
36
37
  export function GPayOption(props: GpayOptionProps) {
37
38
  const [formError, setFormError] = useState(null);
39
+ const [errors, setErrors] = useState([]);
38
40
 
39
41
  const { preOrder } = useAppSelector((state: RootState) => state.checkout);
40
42
  const isPaymentStepBusy = useAppSelector(
@@ -65,6 +67,14 @@ export function GPayOption(props: GpayOptionProps) {
65
67
 
66
68
  // this is necessary because we need to set the payment_option after the redirect
67
69
  useEffect(() => {
70
+ const posErrors = getPosError();
71
+
72
+ Object.keys(posErrors ?? {})
73
+ .filter((key) => key !== 'gpinstallment')
74
+ .forEach((item) => {
75
+ setErrors((prev) => [...prev, posErrors[item]]);
76
+ });
77
+
68
78
  setPaymentOption(preOrder.payment_option.pk);
69
79
  // eslint-disable-next-line react-hooks/exhaustive-deps
70
80
  }, []);
@@ -107,6 +117,13 @@ export function GPayOption(props: GpayOptionProps) {
107
117
  {formError}
108
118
  </div>
109
119
  )}
120
+ {errors && (
121
+ <div className="w-full text-xs text-start px-1 mt-3 text-error">
122
+ {errors.map((error) => (
123
+ <div key={error}>{error}</div>
124
+ ))}
125
+ </div>
126
+ )}
110
127
  </form>
111
128
  );
112
129
  }