@akinon/pz-gpay 1.119.0-rc.2 → 1.119.0

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/CHANGELOG.md CHANGED
@@ -1,18 +1,6 @@
1
1
  # @akinon/pz-gpay
2
2
 
3
- ## 1.119.0-rc.2
4
-
5
- ### Minor Changes
6
-
7
- - 6ad72e8d: ZERO-4032: Add loading state management for payment submissions across multiple components and add safe guarding
8
-
9
- ## 1.119.0-rc.1
10
-
11
- ## 1.119.0-rc.0
12
-
13
- ### Minor Changes
14
-
15
- - 6ad72e8d: ZERO-4032: Add loading state management for payment submissions across multiple components and add safe guarding
3
+ ## 1.119.0
16
4
 
17
5
  ## 1.118.0
18
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-gpay",
3
- "version": "1.119.0-rc.2",
3
+ "version": "1.119.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
@@ -19,7 +19,7 @@ import {
19
19
  } from '../endpoints';
20
20
  import { twMerge } from 'tailwind-merge';
21
21
  import { Button } from '@akinon/next/components/button';
22
- import { getPosError, checkPaymentWillRedirect } from '@akinon/next/utils';
22
+ import { getPosError } from '@akinon/next/utils';
23
23
 
24
24
  type GPayForm = Record<string, never>;
25
25
 
@@ -61,7 +61,6 @@ const defaultTranslations: GPayTranslations = {
61
61
  export function GPayOption(props: GPayOptionProps) {
62
62
  const [formError, setFormError] = useState<string | null>(null);
63
63
  const [errors, setErrors] = useState<string[]>([]);
64
- const [isProcessing, setIsProcessing] = useState(false);
65
64
 
66
65
  const translations = { ...defaultTranslations, ...props.translations };
67
66
 
@@ -73,46 +72,25 @@ export function GPayOption(props: GPayOptionProps) {
73
72
  const {
74
73
  handleSubmit,
75
74
  control,
76
- formState: { errors: formErrors, isSubmitting }
75
+ formState: { errors: formErrors }
77
76
  } = useForm<GPayForm>({
78
77
  resolver: yupResolver(gpayFormSchema)
79
78
  });
80
79
 
81
80
  const [setPaymentOption] = useSetPaymentOptionMutation();
82
- const [setGPayMethod, { isLoading: isSettingMethod }] =
83
- useSetGPayMethodMutation();
84
- const [setCompleteGPay, { isLoading: isCompleting }] =
85
- useSetCompleteGPayMutation();
86
-
87
- const isButtonDisabled =
88
- isSubmitting ||
89
- isPaymentStepBusy ||
90
- isSettingMethod ||
91
- isCompleting ||
92
- isProcessing;
81
+ const [setGPayMethod] = useSetGPayMethodMutation();
82
+ const [setCompleteGPay] = useSetCompleteGPayMutation();
93
83
 
94
84
  const onSubmit: SubmitHandler<GPayForm> = async () => {
95
- if (isButtonDisabled) return;
85
+ if (isPaymentStepBusy) return;
96
86
 
97
- setIsProcessing(true);
98
87
  setFormError(null);
88
+ await setGPayMethod();
99
89
 
100
- try {
101
- await setGPayMethod();
90
+ const response = await setCompleteGPay().unwrap();
102
91
 
103
- const response = await setCompleteGPay().unwrap();
104
-
105
- if (response?.errors?.non_field_errors) {
106
- setFormError(response.errors.non_field_errors);
107
- setIsProcessing(false);
108
- return;
109
- }
110
-
111
- if (response?.errors || !checkPaymentWillRedirect(response)) {
112
- setIsProcessing(false);
113
- }
114
- } catch (error) {
115
- setIsProcessing(false);
92
+ if (response?.errors?.non_field_errors) {
93
+ setFormError(response.errors.non_field_errors);
116
94
  }
117
95
  };
118
96
 
@@ -159,7 +137,6 @@ export function GPayOption(props: GPayOptionProps) {
159
137
  data-testid="gpay-payment-button"
160
138
  className={twMerge('w-full mt-3', props.buttonClassName)}
161
139
  type="submit"
162
- disabled={isButtonDisabled}
163
140
  >
164
141
  {translations.button}
165
142
  </Button>