@akinon/pz-gpay 1.96.0-rc.57 → 1.96.0-rc.59
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 +8 -0
- package/package.json +1 -1
- package/readme.md +6 -2
- package/src/views/gpay-option.tsx +24 -9
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -106,7 +106,7 @@ const GPay = () => {
|
|
|
106
106
|
],
|
|
107
107
|
button: 'Pay Now'
|
|
108
108
|
},
|
|
109
|
-
customUIRender: ({ handleSubmit, onSubmit, translations }) => (
|
|
109
|
+
customUIRender: ({ handleSubmit, onSubmit, translations, loading }) => (
|
|
110
110
|
<form
|
|
111
111
|
onSubmit={handleSubmit(onSubmit)}
|
|
112
112
|
className="p-6 bg-white rounded-md space-y-4"
|
|
@@ -121,7 +121,11 @@ const GPay = () => {
|
|
|
121
121
|
type="submit"
|
|
122
122
|
className="w-full h-10 bg-black text-white rounded"
|
|
123
123
|
>
|
|
124
|
-
{
|
|
124
|
+
{loading ? (
|
|
125
|
+
<LoaderSpinner className="w-5 h-5" />
|
|
126
|
+
) : (
|
|
127
|
+
translations.button
|
|
128
|
+
)}
|
|
125
129
|
</button>
|
|
126
130
|
</form>
|
|
127
131
|
)
|
|
@@ -44,6 +44,7 @@ type GPayOptionProps = {
|
|
|
44
44
|
control: Control<GPayForm>;
|
|
45
45
|
errors: FieldErrors<GPayForm>;
|
|
46
46
|
translations: GPayTranslations;
|
|
47
|
+
loading: boolean;
|
|
47
48
|
}) => ReactElement;
|
|
48
49
|
};
|
|
49
50
|
|
|
@@ -78,19 +79,32 @@ export function GPayOption(props: GPayOptionProps) {
|
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
const [setPaymentOption] = useSetPaymentOptionMutation();
|
|
81
|
-
const [setGPayMethod] =
|
|
82
|
-
|
|
82
|
+
const [setGPayMethod, { isLoading: isGPayMethodLoading }] =
|
|
83
|
+
useSetGPayMethodMutation();
|
|
84
|
+
const [setCompleteGPay, { isLoading: isCompleteGPayLoading }] =
|
|
85
|
+
useSetCompleteGPayMutation();
|
|
83
86
|
|
|
84
87
|
const onSubmit: SubmitHandler<GPayForm> = async () => {
|
|
85
|
-
if (isPaymentStepBusy) return;
|
|
86
|
-
|
|
87
88
|
setFormError(null);
|
|
88
|
-
await setGPayMethod();
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
try {
|
|
91
|
+
await setGPayMethod().unwrap();
|
|
92
|
+
} catch (e) {
|
|
93
|
+
setFormError(translations.error);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
91
96
|
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
try {
|
|
98
|
+
const data = await setCompleteGPay().unwrap();
|
|
99
|
+
if (data?.errors?.non_field_errors) {
|
|
100
|
+
setFormError(data.errors.non_field_errors);
|
|
101
|
+
}
|
|
102
|
+
} catch (e: any) {
|
|
103
|
+
const msg =
|
|
104
|
+
e?.data?.errors?.non_field_errors ??
|
|
105
|
+
e?.data?.detail ??
|
|
106
|
+
translations.error;
|
|
107
|
+
setFormError(msg);
|
|
94
108
|
}
|
|
95
109
|
};
|
|
96
110
|
|
|
@@ -113,7 +127,8 @@ export function GPayOption(props: GPayOptionProps) {
|
|
|
113
127
|
onSubmit,
|
|
114
128
|
control,
|
|
115
129
|
errors: formErrors,
|
|
116
|
-
translations
|
|
130
|
+
translations,
|
|
131
|
+
loading: isGPayMethodLoading || isCompleteGPayLoading || isPaymentStepBusy
|
|
117
132
|
});
|
|
118
133
|
}
|
|
119
134
|
|