@akinon/pz-gpay 1.19.3 → 1.20.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/views/gpay-option.tsx +17 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -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
|
}
|